Where I can take the two items returned in a list as ‘keys’ and name them, so the 1st one is “keyword” and the second one is “URL” but as the editor won’t even let me save this I’m obviously doing something wrong. Is this a syntax problem or am I trying to do something that simply can’t be done this way? In short, I need a way of editing the JSON response I get back from the API so I can more easily target those Keys.
In a perfect world, I’d want the JSON to look more like this:
You cant. The response you manually enter in API response must fit the body returned by API.
But Im not sure to understand your real issue around this. If the API always return keywords as the first item in array and the url as second, why this is an issue for you?
I discovered a way using POSTMAN. Set what you want in a PAYLOAD and initialize Bubble API.
By what I saw, there is no way to set it manually in Bubble (it is not allowed).
But when I try and do it on one of the keys e.g. the first item (which is keyword/query) or the last item (which is the url/page), then I get an error:
I understand what you mean now and why this create issue with sorting.
Some idea I can see:
A) Create a plugins. But honestly, this is complex. Output an object for server-side/client-side
B) Create Two API Call. One will get data as text (what you actually get). Action will transform the payload to fit the one you want and output a json file (using a plugin like : Generate and Download Files Plugin | Bubble)
The second API Call will do a GET request to the created file url
C) Use another tool like Integromat. You have one API Connector that call Integromat endpoint, Integromat call the API you want, transform the JSON payload and return it at the end
Thanks for this. Agree something like Integromat is probably the easiest solution but I was trying to avoid that route but it might work for me short term.
I did sort of try option B - I returned the data from the API as text and then I used the Simple JSONata plugin to transform it to the format I wanted (which worked) but then I got a bit lost as to how I work with that transformed data. Maybe I’ll have another play with that route.