Simple API call

Hi there fellow coders,

I encountered a strange fenominon while working with a simple API call that works fine in Postman.
Maybe anyone can explain what is going wrong.

I am trying to log into the database with the trips of our animal ambulances that are collected by our provider who put GPS trackers in our cars. I have to get back a Bearer token in return to access my trip database.

The format is according to what they tell me to put in the JSON Body and it works great in Postman.
I cant figure out what is wrong in theBubble API connector plugin.

This is my call:

This is the result that tells me nothing…

Thanks for reading

Cornelius

Hi @Polar

Try adding a Header where the key is Content-Type and the value for that key is application/json

If there are still issues, post a picture of your working postman call and somebody will likely spot the problem.

1 Like

Also @Polar, it looks like what they’re asking you to do is use oAuth 2 authentication. Bubble can handle this for you automatically most likely. Look at and read about the OAuth2 Custom Token authentication in the Reference for information on how to configure that:

Thanks @mebeingken
That did the trick!

Hi @keith,

Tried this, it has some great benefits when it should work, but it won’t, any bright suggestions?

Thanks for both your support.

Well, you probably need to set a header for the token call’s content type:

Headers > Click Add header

Header: Content-Type Value: application/json

Hi @keith,

that gave this sad result:

Since we can’t see your settings for that authentication call, we can’t advise further… We need the error (which you provided) and also what your API Connector settings for that look like.

Hi @keith,
Everything works fine in Postman and when I use the settings that are posted above.
Like I said before it is a straight forward simple api call, but Bubble api connector hickups on it.

This is the setup that Ritassist states on their website.
My credentials are the same as in Postman where it works fine so I don’t understand what is going wrong…

Not helpful. Post your “identical” Bubble settings to what Postman is doing for you.

NOTE/hint: Postman sets headers and stuff automatically for you. Don’t forget to look at that. I find it helpful to look at the curl sample (and others) of Postman’s configured call to understand everything that’s required to duplicate the setup in Bubble.

@keith

Like I said its a pretty straight forward call in Postman:

Anyone???

@Polar Try exporting cURL from Postman and test in command line to eliminate any workarounds / gaps by Postman. If that also works, include it in your email to support and we can check if there are limitations on our end.

@neerja,

Thanks for your reply.
I tested it with the data I extracted from Postman.
When I use Authentication None or self handled and use my credentials in the body of my POST call I only have to put a header content-type: application/json before the body part to get it working fine.

When I use Authentication OAuth2 Custom Token, use Custom endpoint POST: https://api.ritassist.nl/api/session/Login
put a header content-type: application/json before the same body credentials and what call whatsoever follows, i get this error:

There was an issue setting up your call, ERR value is not an integer or out of range.

Problem is that when I can’t use the Oauth2 Custom Token my bearer token will not be refreshed automatically…

Kind regards,

Cornelius

@Polar It’s hard to tell where the limitation is with that particular API’s call. Please send Support the cURL for the working Postman call in a bug report and we can try a few variations for Oauth2 Custom Token method in the API Connector.

Sorry to drag up an old thread but I’m an API newbie and I have a quick question…

Why do we need to put “Content-Type application/json” in the header when Bubble already gives us the option to choose the Data type here:

Is that Data type dropdown for something different?

Thanks :slight_smile:

This dropdown is for the response and not for the request. This will let Bubble know what to expect back from API. This can be a file, json, xml, text…
The header you set is for the API to know what type of request your send.

Awesome - thank you!

1 Like