[Solved] How do I make a cURL api call using the webAPI?

I have a CURL command that I want to use in Thunkable with an API Post block:

curl -H “Content-Type: application/json” -H “authorization: Token API_TOKENhttps://api.ximilar.com/recognition/v2/classify -d ‘{“task_id”: “TASK_ID”, “records”: [ {"_url": “URL” }] }’

I’m having a hard time figuring out how to set up the part in bold. I’ve never seen a list used as a parameter value. I tried this:

But it gave me an error (“records field required”). I also tried it without the list block but the same error appeared.

Any suggestions?

1 Like

Import the call in a piece of software called postman.

From there you can see any headers you need to set as well as what body and query parameters need to be set. It’s super handy and it’s what I use most of the time when I have to figure out a curl call

Or

Search for a curl to restAPI converter online

See this post @manyone already solved the issue

1 Like

this is the final block that works - it’s calling the correct endpoint /recognition/v2/classify (the above was mistakenly pointing to /detection/v2/detect)

this is based on a classify run to classify only one image. (see object inside list in records parameter). if more photos are needed, simply them as new objects to the list - but then you have to modify the response processing to use a for loop so that the property string “records[1].best_label.name” is adjusted so the index to records reflects the current value.)

3 Likes

Thank you! That worked. I had to use Body instead of Query Parameters and I also needed the generate JSON from object block.

2 Likes

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