I am trying to call an external API (typeform). So far I tried to call typeform using the API connector.
The problem I am facing is that the structure of the body for the API call can be very complex. The default way of providing a template body and using parameters is not sufficiently flexible for my use case.
I am trying therefore to create this body structure using Javascript. Problem I am facing is that I cannot find a way to have a javascript creating as output a JSON object and having his JSON object being used as the body of the API call.
Add in headers, Content-type with value to application/json
Just to be sure, I suggest you to create a requestbin (https://requestbin.com/)
and send the request there just to see what is received.
If you make it public, you can share the link and have a look too.
Content-type is already defined as application/json. When I hardcode a JSON object in the body, it works fine.
Problem comes when I try to generate the JSON using Javascript. Problem I think is that the Javascript cannot communicate directly with the API call and must go through a text element.
Captain Obvious didnāt score this time, hahaa. Another possible problem is those funny slanting double quotes, Iāll assume thatās an artifact of this forum.
Perhaps it is a matter of timing? Bubble workflows are finicky with page elements, they tend to use the values as they are at the start of the workflow, even if the values change before the API call action.
First of all, thanks so much for suggesting the use of requestbin, really good idea.
Using that tool I understood that the variable created by a Javascript just before the call to the API is not accessible.
So I created a flow where when the user clicks on a button, it triggers an event which fills a variable. Then when this variable changes it triggers another event. At that point the variable is visible.
Very happy to be able to continue using Bubble otherwise this one would have been a showstopper.