Web API query parameter - pass variable data?

We’re being caught up in terminology here; I’m no expert but as far as I know, we call query parameters the stuff that goes after the ? in the URI - this is because the URI is the query and the stuff that comes after the ? are the parameters. The stuff that we usually POST is the body which, as far as I know, we just call the body since it’s contents are not “standard” - they might be some sort of parameters or they might just be binary data or anything else - so we GET with parameters and POST with body (although that’s really just the “correct” implementation, both methods will actually have all the information available on the server side).
In any case; you are probably right in that what you want to send should go in the body (since you’re talking about the POST method). Since you need to send it url encoded, I THINK THunkable does that automagically.
So you should try:

  1. in the Web API component’s definition, add a header called “Content-Type” with the value that you mentioned is expected “application/x-www-form-urlencoded” (double-check spelling and everything)
  2. in blocks, set the WebAPI’s body to the text that you want
  3. Call the POST method.

If it doesn’t work, there are services online that may help by replying back exactly what you posted (eg. point your WebAPI component to one of those test services and then print their response to a textbox). Example project: https://x.thunkable.com/copy/e1e499726756be82d83979fe0831fbbc
(you’ll notice that this project is pointing to httpbin.org which will reply back the request that we send…)

edit: corrected the content type as mentioned (I’m really just copy/pasting yours here, I only really use json with my WebAPIs :slight_smile:)

1 Like