How to use web api with post + parameters and with form

I need to send a post request with two parameters using application/x-www-form-urlencoded (with form basic). The response is an authorization token. How should I create this web api block? I’m new with thunkable.
Grateful

1 Like

Welcome to Thunkable.

Use the body block of the Web API for the parameters as if you are writing these parameters in the URL in the browser.

There are some examples of this here:

1 Like

munner,
How should I specify the content-type? Do I use object or a string in headers?
I adjusted as you said, but it keeps returning error. See the image of the current code.

Thanks for the help.

1 Like

Please see the link to the topic I posted above. It shows a screenshot with the Content-Type configuration.

It’s going to be really hard to troubleshoot any errors you’re getting without:

  1. Knowing what the exact error message is
  2. Either having a link to the documentation or knowing the API url
1 Like

It would be very helpful to know the error so if you do this condition to show what kind of error you are getting.

In your case, you are displaying the header whether there is an error or not.

1 Like

munner, I still haven’t gotten the expected result. For better understanding, look at this request image by bummerang. The API requests a post using form basic with the two parameters indicated, and the response must be sent with sent request. In this case I need to get the authorization content

.
Thanks.

1 Like

Set another header called Authorization and feed it Basic <ya.accessTokenValueGoesHere>

You should print your error messages to a label. It will be helpful to know what error is occurring when you make the call

I made this quick setup

I got this response

muneer,
You are using the authorization field. This field should not be used in the post request, as per API documentation. This post gives me this authorization back, but I can’t receive the content of this authorization. How should I code the post so that it receives this authorization by just sending the two parameters and the header with the content-type? I’m not having success

1 Like

You need to make a code similar to this
image

However, you need to check with the documentation of this API to supply the correct parameters in the body block.

Alternatively,
You can use my Encrypt / Decrypt demo project to convert the entries to the required coded string for authorization

https://x.thunkable.com/projectPage/60ba3f2079d6dc001150abe7

2 Likes

munner, thanks for the valuable guidance.

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.