Postman Request Works but API Connector Request Not Working

Hello,

I’ve used Postman to create an API call and it is working fine.

Once I try to bring the same parameters over to the API Connector I keep getting a response that shows “400” and that the parameter “grant_type” is a missing parameter when you can clearly see it has been added to the body of the API call that I am initializing.

Can anyone figure out why this is occurring and how I can fix it.

Thank You,

Gabriel

I guess that api expect json. Add header: Content-Type
with value to
application/json

Thanks for the response.

I’ve tried that.

It actually has to be URLEncoded. Which works in Postman.

I just can’t get it to work in API connector. It’s so strange because the “grant_type” parameter is clearly being sent in the request.

In this case, I suggest you to use the Correct content type in header.
Can you share the Postman Call so we can compare.
I suggest you to also send the request to requestbin.com url so you can compare the output and do the correction

Hello,

I’ve tried to add the Content-Type application/x-www-form-urlencoded value to the body parameters of the request as well in API connector and it still hasn’t worked. I’ve basically tried everything.

It still is working fine in Postman.

Here is my request and you can see the successful response.

Can you send the request to a requestbin And show the result (including headers)

I’ll have to do that later and let you know.

This request in Postman is going through with no Headers and successful.

I’m trying to use RequestBin right now and it is a little different.

Any suggestions how I can rig it up similar to Postman request ?

It doesn’t seem so user friendly.

Thanks,

Gabriel

Hi @Jibbystyle,

I would suggest checking what headers Postman has added onto this, make sure all are reflected in your API Connector, this is often what is making it not work in bubble :slight_smile:

Check under temporary headers too for things like “Accept”, “Response”, etc.

1 Like

Requestbin will show you exactly the content of your request. You canbyse the same url to send from postman and send from Bubble and compare both to 7nderstand the difference between each call. Most of the time this is related to header. I think that you should send screenshot of header and content received by requestbin so it will be easier for us to help you. You can also share the requestbin url so we can see it ourself (the url that show you the result of the request, not the url used to send the request). Only if you make it public

Hello,

I just tried adding all the temporary headers to my call in API connector.

I am still getting the same 400 response saying the “grant_type” parameter form is missing.

It just doesn’t make any sense that it is working in Postman and not API Connector.

I’ve tried everything. I also tried to add application/x-www-form-urlencoded to the body of the JSON.

It appears to be that way in the Postman request.

I’m not sure what to do at this point. Any ideas would be greatly appreciated.

Thanks,

Gabriel

Because you seem to have trouble to understand how requestbin work, I’ve done test myself.
So if you just put no header and send your request, the content type is set to application/json.
If you add a header set to application/x-www-form-urlencoded, this will, again, overwrite and be application/json (this is why I tell you to test with requestbin because API connector in Bubble have some strange behavior that I’ve already discussed in another topic).

Now. If you keep the header and put {} in json body, you will have the right header… but parameters will not be sent.

Now let’s try something else. Instead of adding parameters, we will add it in the url like ?grant_type=[grant_type] … this will be application/x-www-form-urlencoded and grant_type will be sent as query parameters. This is better, but not perfect.

Finally, Try:
Content type header set to: application/x-www-form-urlencoded
Clear all other parameters, don’t set any parameters in url. And use a json body like:

{
"grant_type":"<grant_type>"
}

It’s work.

I know, it doesn’t make sense, but it’s actually how this work.

2 Likes

Hello,

I just wanted to say Thank You so much for your time and effort on this subject.

I am going to digest this new concept and sleep on it as I’ve burnt myself out on this the last few days.

I will get back into it and try what you’ve suggested tomorrow or Monday.

Thanks again for the extremely valuable information and help with this issue.

1 Like

This is not really your issue but more a strange behavior od the API connector. It’s always hard to find when you don’t know which tool you can use to debug that.

Hello,

I am attempting to follow your instructions and I apologize if I did it incorrectly but I am still receiving the same 400 error message.

Here is a snapshot of what I did. Not sure if I did correctly. Any other advice or suggestions would be appreciated greatly.

Thanks,

Gabriel

do you have link do API Doc?
If you have correct informations in each fields, this look ok. 400 mean an authorization issue. The request is ok but maybe other information are not. Also, in some API’ you need to authorize the correct domain in API info.
Did you get any error message with the 400?

Same thing I keep getting. Strange cause it still works fine in Postman.

There was an issue setting up your call.

Raw response for the API
Status code 400
{“error”:“invalid_request”,“error_description”:“Missing form parameter: grant_type”}

My mistake. 400 is error on request not auth. Do you have the direct link to API doc so I can check and let you know

copilotapi.integratepayments.com

Endpoint : https://accountsuat.cardconnect.com/auth/realms/cardconnect/protocol/openid-connect/token

I’ve tried using version headers as well.

Still working in Postman fine.

Thanks for the help.

I think I found a way to make it work but not sure because I don’t have any key.
Try this
In header;
Content-Type value set to application/x-www-form-urlencoded
No parameters
body
grant_type=password&username=yourusername&password=yourpassword&client_id=yourid&client_secret=secretkey

This is similar that if you encode it in url.

Let me know!

3 Likes