Can’t execute a simple curl command?

I’m SSHing into my router to try and run some simple curl commands. To whit

curl -X POST -H "Content-Type: application/json" \
    -d '{"Token": "MyToken"}' \

This gives me an error msg:

{“code”:-1,“msg”:“Token is null”}

What am I doing wrong? I’m fairly certain I have the correct Authorization code in my command.

You’re about to mix up two communications.

  1. connect per ssh and execute local commands.
  2. connect per curl and use the well documented API

It is not useful to login remote to send a http request.
In the API documentation is the very first part ‘Authentication’ (okay, the second, after ‘Prepare the Environment’).

Maybe the API differs from your device. It is useful to know against what device/firmware you are executing the curl-request.

Did you get the token like so?

curl -d "pwd=YOUR_ROUTER_PASS"

The token you get from the above login command you use bellow

curl -X POST -H "Content-Type: application/json" -d '{"Token": "TOKEN_HERE"}' 

Yes, I tried that and get

{"code":-1,"msg":"Token is null"}

I’ll get the same at my Beryl (snapshot Firmware).

Does ‘router/hello’ works for you?

lupus@kira:~$ curl -k -X GET -H "Content-Type: application/json"

I don’t think it is a SSL issue, because http:// give the same result.

On my SlateAX, I get as result only ‘403 Forbidden’. But I have no time to find the right switch, right now. I’ll try this weekend, again.

HINT: Don’t use !! in your Password. At least Linux Bash will expand !! to ‘last command’. Very disturbing.

Else it is working on Beryl with the explaination from @alzhao.

curl -X POST -H "Content-Type: application/json" \
             -H "Authorization: YOUR-ACTUAL-TOKEN" \
             -d '{""}' \
1 Like

Where does the actual token (assume ABCDEFG) go?

My ultimate goal is to connect/disconnect to one of the defined OpenVPN or WireGuard clients

I modified my answer. Hope it is clear now.

Please remove the brackets and change text to caps, ie

   -H "Authorization: YOUR-ACTUAL-TOKEN" \

So the next guy that sees this won’t include the brackets.

1 Like

Changed. Thanks for your suggestions.