Consume API with Content-Type application/x-www-form-urlencoded

Hello, I'm try consume the API from Spotify.

I want get token according the API documentation

https://developer.spotify.com/documentation/general/guides/authorization-guide/#authorization-flows

In the test API, I'm get the token, but I can't get token in runtime.


The Screenshot for the test API is good.


Input and output parameters


In a runtime


The error in the page is 400 Bad request.


Any idea?


Thanks

Solution

Your API call should have a single input parameter of type Text, with option "Send in Body".

This parameter should be set to the value in your first picture:


"grant_type=client_credentials&client_id=" + ClientId + "&client_secret=" + ClientSecret


Additionally, I would edit your post to hide your API credentials, as they could be used by someone else to access your account.

Solution

Hey Alejandro,


Just discovered this guide, seems to be exactly what you're looking for: https://www.outsystems.com/forums/discussion/36156/guide-consume-rest-api-with-form-url-encoded-request/

Gonçalo Soares wrote:

Your API call should have a single input parameter of type Text, with option "Send in Body".

This parameter should be set to the value in your first picture:


"grant_type=client_credentials&client_id=" + ClientId + "&client_secret=" + ClientSecret


Additionally, I would edit your post to hide your API credentials, as they could be used by someone else to access your account.

Hi Gonçalo,

Your answer is correct and very well explained, and I would like to emphasize one more detail I have already experienced.
When filling in the body of the request, it is necessary to hide the username and password not to send special characters.

Eduardo Benites


Gonçalo Soares wrote:

Your API call should have a single input parameter of type Text, with option "Send in Body".

This parameter should be set to the value in your first picture:


"grant_type=client_credentials&client_id=" + ClientId + "&client_secret=" + ClientSecret


Additionally, I would edit your post to hide your API credentials, as they could be used by someone else to access your account.

Thanks, it worked.

With respect to credentials, they are just sample credentials.