301 error when attempting to start zone

I’m trying to start a zone via the API. Below is the command I’m running… sanitized for privacy.

curl -X PUT -H “Content-Type: application/json” -H “Authorization: Bearer AUTH-KEY-HERE” -d ‘{“id” : “XXXX-ZONE-ID-HERE”, “duration” : 60}’ https://api.rach.io/1/public/zone/start

The Zone ID I am using is the Zone ID I retrieved when running the below command, and pulling the “id” within the zones JSON response.

curl -X GET -H “Content-Type: application/json” -H “Authorization: Bearer XXXX-AUTH ID” https://api.rach.io/1/public/device/XXXX-DEVICeID

C:\Users\me>curl -X PUT -H “Content-Type: application/json” -H “Authorization: Bearer XXXX-AUTH-ID” -d ‘{ “id” : “XXXX-ZONE-ID”, “duration” : 60 }’ https://api.rach.io/1/public/zone/start
curl: (6) Could not resolve host: id
curl: (3) Bad URL, colon is first character
curl: (6) Could not resolve host: XXXX-ZONE-ID,
curl: (6) Could not resolve host: duration
curl: (3) Bad URL, colon is first character
curl: (6) Could not resolve host: 60
curl: (3) [globbing] unmatched close brace/bracket in column 1
{“code”:“301”,“error”:“field name id required. Error message is Unexpected End Of File position 2: null”}

I’m assuming i’m formatting it wrong, but i’m not sure what’s wrong. Any assistance would be greatly appreciated.

Yes, it’s a shortcoming of the Windows DOS prompt. I took the example from

curl -X PUT -H "Content-Type: application/json" -H "Authorization: Bearer 8e600a4c-0027-4a9a-9bda-dc8d5c90350d" -d '{ "id" : "d3e99d27-25e4-47dd-b354-1db5a84c99d7", "duration" : 60 }' https://api.rach.io/1/public/zone/start

and it ran “fine” at a Linux bash prompt, i.e. it gave the expected ‘client is not authorized’ error.

But typing the same string into Windows got the same errors as you.

Editing it to
curl -X PUT -H "Content-Type: application/json" -H "Authorization: Bearer 8e600a4c-0027-4a9a-9bda-dc8d5c90350d" -d "{ \"id\" : \"d3e99d27-25e4-47dd-b354-1db5a84c99d7\", \"duration\" : 60 }" https://api.rach.io/1/public/zone/start
gave the desired result.

1 Like