How could I possibly edit JSON file which is returned from an API call?

Hi, all! How could I possibly edit JSON file which is returned from an API call? Thank you!

Hi @d.norkus

The “how” depends on …

Is the JSON being returned as the response body text, or as an attached file?
Where do you want the resulting edits to go?
Is the API called from a page workflow or from an API workflow?
Which API? Someone might be familiar with using it.

1 Like

Hi @mishav! Thank you for replying!
Basically, I need to make chart using amCharts plug-in. I get the data into element’s source field as a data from an external API (using plugin API connector and returned data as a JSON body text) basically is a list of dates, TotalAssets, ShareholderEquity. For every thing, additionally, I need to calculate total liabilities which is TotatlAssets - ShareholderEquity. And here is where the tricky part starts… In the source field of the element I can :sort, :filtrate :add etc. things on the list, however I can’t manipulate the numbers inside the thing of a list :thinking: So, I thought of possibility if such to edit the returned JSON data.

Hi @d.norkus, what might help is to return the API data as a Text instead of JSON, then you can send the Text to Javascript for manipulation.

From there, you can either return the values back to Bubble to send to the amCharts plugin, or you could send the data directly to the charts javascript library.


Hey again, @mishav!:raising_hand_man: I have managed to update text with Javascript, but struggling to return data back to Bubble or I do some errors in reading returned data…:thinking:

just for testing I am trying to display the values in a RepeatingGroup…

Hi @d.norkus

Button workflow:

  • API call

  • run javascript

    var data = result of step 1;

JavascripttoBubble workflow:

  • Set RG data source with this element’s list of texts

I am still getting this error:
Error - Element JavascripttoBubble - Trying to send an invalid array to Bubble [object Object]

could this error happen because the list contains an array structure inside?

I have already solved it, @mishav :wink: Thanks!

1 Like

What was the solution?