[ardoJSON] Google Books API integration

[ardoJSON] Google Books API integration

  
Forge Component
(21)
Published on 30 Aug by Ricardo Silva
21 votes
Published on 30 Aug by Ricardo Silva
Hi there, i'm using the ardoJSON extention to integrate the google books api but i'm having some problems.
This is the link that generate the JSon content to transform in a record list on Outystems Platform:

https://www.googleapis.com/books/v1/volumes?q=harry+potter&maxResults=1

T
he follow error occurs on service center:

Message:
Unable to cast object of type 'Newtonsoft.Json.Linq.JArray' to type 'Newtonsoft.Json.Linq.JObject'.
Stack:
at OutSystems.NssardoJSON.CssardoJSON.readSimpleValue(JToken json, Type fieldType)
at OutSystems.NssardoJSON.CssardoJSON.readRecord(JObject json, Object rec)
at OutSystems.NssardoJSON.CssardoJSON.MssJSON2RecordList(String ssJSON, Object ssRecordList)
at ssBookify_Amazon_WS.RssExtensionardoJSON.MssJSON2RecordList(HeContext heContext, String inParamJSON, Object inParamRecordList)

 

If anyone knows why let me know.
Thank u
Best Regards
Miguel Grilo
Hi Miguel,

It seems like the error stems from a structural mismatch between JSON and the OutSystems structure (it's expecting an array because it has a record list and getting an object).

[EDIT] Actually, in this case it's the other way around. It's getting a JSON array when it's expecting an object (because on the structure it was defined as Record)

Can you provide us with the eSpace you're trying to consume this API ?
Hi Ricardo thanks for the fast reply
There's the OML that consume the API, only have test pages and nothing else.

Cheers
Miguel Grilo
I made the following changes and could make it work with that JSON:

Wrapper Structure: change items type from Record to Record List
VolumeInfo Structure: change authors type from Record of authors to Record List of Text

Let me know if that also works for you.
Thanks Ricardo i've tested and works fine to!

Best Regards 
Miguel Grilo