How to post Rest api using a client


I downloaded an Android Rest client but the problem is that I do not know how or what to post using this. I know the curl -X -H … stuff. That works in the commandline well however I want to use this client. I tried bunch of headers post stuff without knowing what I am doing, naturally all failed ;(

The client offers POST , Http headers etc.

My question is that what kind of POST Header am I supposed to choose and do I need the body for the post?

I realize this is not necessarily a ST related questionb, but it might help others in case they want to give that method a try.

The one I am trying to use is “Rest CLient for Android”

I’m new to this as well, but I’ve had some success interacting with the REST api with Powershell. As an example, this restarts Syncthing:

$ApiKey = “ifhgrnjtwoerhtdlkfjgnfidhfg” (You find it in the settings of Syncthing) $Url = "http://localhost:8384/rest/system/restart" Invoke-RestMethod -Uri $Url -Method Post -Headers @{“X-API-Key” = $ApiKey}

So to answer your question: You dont always need a body. If you’re posting a config, the config is the body. But in my example, no body is posted. But the header contains the API key. But I do not know how to write the header in the rest client you are using. I would guess it’s the same format as in Curl.

Keep in mind I’m no expert at this, I’ve just started learning and experimenting myself.

1 Like

The Method should generally be POST; the URL is clear I think. Everything you addred with -H to curl are headers in form of Name:Value which you have to add inside the app. If you used the -dparameter with curl, that’s the body (I think)

If this is the app you are referring to, than the screenshot shows a Header which would be -H "Accept:application/json" when using curl.

Thanks for the reply. But still I am confused

So this is the command line I am using curl -X POST -H X-API-Key:xxxxxxx-yErLta0scTx5ZYXLTawH

Now where do I put the “X-API-Key:xxxxxxx-yErLta0scTx5ZYXLTawH” part ?

So in other words, is X-API-Key equivalent to the “Accept” in the example?

Also is it possible to scan all the folders with a single POST? So that I do not have to create many profiles?

Yes, X-API-Key is the header name and your actual key is the header value.

I just checked what the Web UI does when clicking the rescan all button: it sends a POST to /rest/db/scan (no folder parameter).

1 Like

Thanks for your help

I tried it without the folder part it does not work for me ;(

Edit: I think that it was an issue with the client’s time out.