Can't figure out http api v2.0 requests

rankzy

Cadet
Joined
Mar 24, 2022
Messages
4
I try to make a php script to start a jail and I found out that best way is to use the api v2.0.
But first I want to just try curl in cmd but can't figure out how to do it.
This is what I have:
Code:
curl -X POST "http://192.168.1.200/api/v2.0/jail/start" -H "accept: */*" -H "Authorization: Bearer 1-xxx" -H  "Content-Type: application/json"

I don't know where to specify the jail name either.
The response I get is just a number that increases by 1 every time I redo the request.
 

Samuel Tai

Never underestimate your own stupidity
Moderator
Joined
Apr 24, 2020
Messages
5,398
Have you looked at the REST API v2.0 documentation? To specify the jail in the POST, use -d "<name of your jail>" at the end of your curl string.
 

rankzy

Cadet
Joined
Mar 24, 2022
Messages
4
Thanks for the reply, i looked at the api docs on my truenas server and there is not imformation.
Now the response is:

{"message": "Expecting value: line 1 column 1 (char 0)"}
 

Samuel Tai

Never underestimate your own stupidity
Moderator
Joined
Apr 24, 2020
Messages
5,398
That unhelpful message typically means to experiment with the quotes. Try this: -d '"<name of your jail>"'.
 

rankzy

Cadet
Joined
Mar 24, 2022
Messages
4
Still the same error
I used:
Code:
curl -X POST -H "Content-Type: application/json" -H "Authorization: Bearer 1-xxx" "http://192.168.1.200/api/v2.0/jail/start/" -d '"<jail_name>"'

with "1-xxx" my api key
and <jailk_name> the name of the jail I want to start
 

theomolenaar

Dabbler
Joined
Jun 12, 2016
Messages
43
Did you find a solution? I'm trying to write a restart jail command.
 
Top