Store REST API output into local storage ?

Store REST API output into local storage ?

  

Hi there,

I am successfully calling a REST API and I can see in my test that it is returning data and the format of the JSON response successfully.

I am using a 'CreateGetOrganizationsResponse' to take the ouput from the REST API call to store it in local storage. However, this only seems to store one entry from the response ??? If I try to point the Source for the CreateGetOrganizationsRepsonse to be the list, it gives me an error.

I'm then using a Card to display the local storage and it only seems to be showing having stored one entry each time it's run.


How do I store the whole JSON response from a REST API call into a database ?


Thanks,
Roy.


Hi Roy,

Without an example eSpace it's a bit difficult to know what you're doing there. Have you checked the output of the REST service is actually a List? What is the "CreateGetOrganizationsResponse" Action? Did you create it yourself? Is "GetOrganizationsResponse" an Entity name? If it is (in which case you should rename it, it's a terrible name!), there's also a CreateOrUpdateAll variant that takes a list, did you look at that?

Regarding the card, what widget did you use inside the card to display the local storage? Why didn't you just debug it to see what's in the local storage?

Looks like the answers is to call my REST API and then have a ForEach Cycle that then calls a 'CreateGet' action that builds up the database from each of the JSON records that are returned from the API call.

Roy.

Hi Roy,

Not quite: this would be the case for a web app, but a mobile app also has a CreateOrUpdateAll variant that actually takes a record list. You can assign the output of the REST directly to its input parameter, and do the mapping* as needed. This is far easier (and performs better) than a ForEach.

*Which is basically just a sequence of assigns.