Help with external API save to database through timer/business logic

Backendless Version Online

Client SDK REST

Application ID 41F831D7-1082-9EE4-FF6C-0E7ED3481C00

Expected Behavior

Please describe the expected behavior of the issue, starting from the first action.

  1. call an external API through a timer (which will eventually run once a week)
  2. save data to database from that api call

Actual Behavior

Please provide a description of what actually happens, working from the same starting point.

Be descriptive: “it doesn’t work” does not describe what the behavior actually is – instead, say “the request returns a 400 error with message XXX”. Copy and paste your logs, and include any URLs.

  1. External API is called
  2. I know the data is being provided by the external api but cant save the body/data elements provided by api.


this is the response, but I can only seem to save the “date_last_run” “date_last_run_timestamp” “name” and “url” to the database using this method:

i have tried to get the property of the “data” elemtn of the json response but it doesnt pull the detail through and save to the database.

Any ideas or suggested tutorials to watch would be greatly appreciated.

1 Like

Hi, @Andrew_Billcliffe

Try to create the column “data” JSON data type in the “awrstest” table before making a request.
Try this logic:

Result I got:

Is this the result you you were looking for?

Regards,
Marina

That’s closer than I got! Thank you, but I actually need a column for each of the fields in the data element of the API response which is what my Bubble app does just now but I find bubble very slow so trying out Backendless after some recommendations.
I’m trying to get all 29 fields of the data response into their own columns.

Hi Andrew,

To do this, extract the value of the data property from the response and pass the resulting object into the Save Object in Backendless block. Please let us know if that approach works for you.

Regards,
Mark

Thanks Mark. I played around with a few things and truth be told i was a little lost but found a very similar topic and your advice on this thread was a huge help! How to get an object from a nested array of objects using Codeless - #7 by Andreas_Marinopoulos

Proof of concept below, just need to build a few blocks to write it to the database now. Any critique on my method?

Its a big learning curve but I’m really beginning to enjoy Backendless!

Hi @Andrew_Billcliffe,

I would do it in the following way, but yours is also good:

Its a big learning curve but I’m really beginning to enjoy Backendless!

Great to hear it!

Regards

Interesting, thanks Stanislaw. Looks like there is potentially less processing involved in your method and potentially faster/easier to execute in the server?

I don’t think there will be any noticeable difference in performance here. The code will execute very quickly, and 99.9% of the execution time will be taken by a request to a third-party API in your HTTP/s block. The only difference I wanted to show is the ability to use fewer blocks without losing readability, thus reducing the number of things that you, as a developer, need to support in the future.

1 Like