How to set dynamic values for API Parameters

I tried to put a random placeholder in the value of a parameter to initialize the API call because the value will be dynamic (coming from the redirect URL after Spotify OAuth). I tried this since I couldn’t leave the field empty or the call wouldn’t initialize.

Is there a way to set this parameter dynamically in the API editor while still being able to correctly initialize the call?

I want the workflow to dynamically pull the correct authorization code when the API call is triggered, but I’m stuck on not being able to initialize the call before using the API call in the workflows.

No, there are no dynamic expression in the API connector, you need to hardcode a value to initialize for most APIs, unless the API provider has a generic value that can be used.

You do not need it to be dynamic in the API connector for it to be dynamic in the action. If it is a parameter, uncheck the box for ‘private’ and it will be available in actions to be set dynamically. If it is a JSON body value use <> and if it is a URL parameter use []…most of that information is actually in the API connector in the corresponding areas.

Screen Shot 2024-09-29 at 11.53.27 PM
Screen Shot 2024-09-29 at 11.53.06 PM

1 Like

Thanks for the info.

I ran the OAuth flow which gave me the code needed for the parameter. I tried initializing and got Status code 415. I double checked and added the headers exactly the way Spotify says to:

I’m confused on what you mean by:
“If it is a JSON body value use <> and if it is a URL parameter use []

Below is a screenshot of my API call. Can you see what wrong?

That is okay, doesn’t look like you are using them anyway

Codes are specific to the API provider, check Spotify documentation on what that code means

1 Like

It means a server has rejected a request because the message content format is not supported.

I read that this is referring to the headers Content-Type. But what I have there is right from Spotifys documentation.

I changed the body type to JSON and now its giving me this error:

Status code 400
{“error”:“unsupported_grant_type”,“error_description”:“grant_type parameter is missing”}

But Spotifys documentation says this to enter “authorization_code” which is what I have.

I switch it to raw and that seems to have worked but now the headers authorization base64 encoded is giving me an error.

if you select JSON and use parameters, Bubble will encode them as JSON even if you set a different content-type. This can be avoided by using the queryst checkbox (but may not be accepted by API endpoint) and sometimes using body with key=value&key=value instead of a JSON.

1 Like

I’m not clear on how to implement your solution. Should I change either the Data type or the Body type to a different format?

Also can you please explain what I need to change after I check the queryst checkbox?

I changed the body type to raw (since form data also returned an error).

This seemed to resolve that issue but not I’m getting this error code:
Status code 400 {“error”:“invalid_client”}

Which means it’s an incorrect authorization header.

Spotify’s documentation:

I encoded my my client id and client secret using “https://www.base64encode.org/” in the format in the image below.

Then I pasted the returned code like this. Am I doing this wrong?