WEB POST with query parameters

Been trying to web POST with the Web component but can't get it to work. Coming from Thunkable, it works flawlessly but can't seem to get it working here.

I have a post request with the following:

And get a 422 error with a
response content of: {"detail" : ["loc":["query","img_link"],"msg":"field required","type":"value_error.missing"}]

I know my API works since it resolved properly with thunkable and using the API test with FastAPI

Anyone have any ideas? I'm thinking 2 possibilites both of which I dont really know how to solve:

  1. The API expects the img_link to be in the query paramaters. Is this what POST does here with Post Text?
  2. The formatting may be incorrectly passed to the POST text since it contains characters such as " / / :"

Try replacing the JsonObjectEncode block and everything after it with a text join block and blocks that build the cloudinary url as you see it in your curl. You might need to insert a uriEncode block, but Posttext usually takes car of that....

unrelated content example for blocks:

Thanks for that. Tried it but its not working yet.

Is there a way to use 'Do it' debug function on the .PostText Method?
I just wanna make sure that the post is sending the correct url form

  1. your request header is not correctly set... also it is not Content-Type but accept...
    the header should be a list of lists.... let me recommend you to use list blocks rather than dictionary blocks... see an example also here how to set the request header https://puravidaapps.com/dropbox.php

    accept
    application/json

  2. set the complete URL in the Url property of the Web component

  3. and in the PostText method just post an empty string

Taifun


Trying to push the limits! Snippets, Tutorials and Extensions from Pura Vida Apps by icon24 Taifun.

Taifun you are a godsend!
That worked flawlessly.
Thanks so much.

Closing this

great that it is working now...
you might want to post a screenshot of your working solution for others, which might have a similar question in future... thank you...

Taifun

Yes. Here is the correct working code:

Thanks so much!

1 Like

Just out of interest, does it also work as I suggested, obviously with the correct headers?

No, I couldnt get it to work with .PostText then using join to form the request.

OK, thanks

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