API Call working on Postman, but not on Bubble

I have tested an API call that works perfectly on Postman, I am sending it as a JSON on postman and it is working perfectly.

However, when I input the same data into Bubble I am getting an error in regards to sending the data to the API even though I am sending it as a data type: JSON.

When I made the call on postman without JSON, I am getting the same error I am now getting on Bubble. But once I sent with JSON, the call worked. Now, I am trying to make the same call in Bubble by sending it as data type: JSON, and getting that same initial error.

What error do you get?

Ignore the API Key part, it’s nothing to do with the API Key. It’s something to do with JSON

Did you add the content-type header? Can you share a screenshot of your Bubble setting?

Sure. Just blacked out sensitive information

Not sure how to add a content-type header but that sounds like what I need.

You can first try first to click on the Add header button and add the content-type header like it’s asked.
Do you have API Doc url?

1 Like

Add your header

still getting same error when added this to header.

Actually, your JSON is probably not correct. For example, yht images is an array and this is not what you have providing.
I prefer to use the JSON body instead of parameters.
Normally, when you use parameters and not the body, Bubble will add the content-type application/json automatically. Just to validate, it’s better to add it.
But webhook = null… will send “webhook”: “null” that is not really a null value, but a text “null”
Bubble always encode parameters as text. So it will also be the case for the array.
So the first step will be to remove all parameters and use the body JSON part. to have dynamic field, you can use <parametername>

1 Like

Will look like:

    "key": "<key>",
    "instance_prompt": "<instance_prompt>",
    "class_prompt" : "<classe_prompt>",
    "base_model_id" : "<base_model_id>",
    "images": [<imagelist>],
    "seed": "<seed>",
    "training_type": "<training_type>",
    "max_train_steps": "<max_train_steps>",
    "webhook": "<webhook>"

(but if webhook can be null… you will need to remove double quotes around it)


thank u sir this solved my problem

1 Like

Thanks, i still have the issue, any chance you can take a look?

this is the postman code:

This is bubble when i turned all into parameters like you said:

gives me error that template parameter wrong

If you look correctly, your JSON is not the same. You forget square bracketer in modifications [ ]
Also, be sure to add the header Content-type: application/jon