Postman - Enable Zone

I am trying to figure out how to enable a zone using POSTMAN.
So far I have my authentication, the userID, device ID and zone Id all stored.

I have tried using both the PUT and a POST. The post returns This returns a code of 405 - Method Not Allowed

When I do the put, it complains about the device ID being blank. The syntax of the PUT in postman is essentially:

PUT https://api.rach.io/1/public/zone/start?id=0f4eb130-aaab-47ec-aab2-8dad79963c67&duration=600

The only example I can find is the CURL example which has slightly different syntax.

Can anyone guide me on how to to this with POSTMAN? I seem to be able to get information from the device easily, but modifying or pushing content to it is not working.

Does the ID have to go in the header? as a paramters? in the body? no matter where I put it the error says that the id field is blank

I presume the id you have listed is the zone ID, correct?

I believe you have it correct as a PUT. However,

The things to try are:

  1. Add authorization, if I remember correctly the API key, but double check (which ends up in the header)
  2. content-type in the header
  3. id and duration in the body

I know I could be wrong on some of this as it makes it closer to CURL. However, I just watch a video on POSTMAN and they talked about all of these elements. I hope this helps in some way.

I think youā€™re trying to start a zone?
Check your header for the right bearer token.
Check your zone id is right.
My bet is you havenā€™t setup the bearer token right in postman. I donā€™t have it right in front of me so I canā€™t tell you what to look for (Iā€™m on my tablet). thatā€™s my guess?

In postman you need to set the header to have the bearer token:
ā€œAuthorization: Bearer 8e600a4c-0027-4a9a-9bda-dc8d5c90350dā€

Note that you have to use your personal API key as the bearer token and you must use the zone id that you get from your zone list for this call to succeed. I assume you knew that but just in case.

Thanks for the reply. I mis-ā€˜spokeā€™ - you are correct, I am trying to start a zone.

The bearer token is inherited from the collection which has it stored. The same collection is performing the GETs to get the id, device id and zone id - all tied to the same token - so I am fairly confident that should be ok.

I have the GETs run and extract the device ID and zone IDs automatically and store them in global variables. Then I pass those through the PUT function setting id to ZoneID that I care about.

Iā€™ve tried to do this manually as well by physically typing the ZoneID in as well and it didnt help.

Do you know about the PUT function - they have options to pass parameters, header, body, etc. Iā€™m assuming the zone id has to be passed as a parameters on the parameters page? Iā€™ve tried it there and in the body and both return errors saying the id field cannot be blank.

ok. I am fairly positive this is what I am doing, but I can double check later today when i get home. The only thing im not sure about is ā€˜content-type in the headerā€™. I need to see how that is setup.

Below are a couple images that should help quite a bit. I do see that you have things stored, but I am simplifying it for others that may view this. I look at POSTMAN as a GUI to cURL.

The content-type is automatically filled in with the way I did it, so you do not have to change that or anything else in the Headers.

As I was expecting, putting the id & duration as part of the URL (or Params) does not work for me and give me:

{
ā€œcodeā€: ā€œ301ā€,
ā€œerrorā€: ā€œfield name id required. Error message is json can not be null or emptyā€
}
I am not sure if this is the error you are getting. You mentioned device ID, but am guessing this might be the issue.

Summarizing what I entered to get it working:

  1. PUT URL
  2. Authorization: Bearer Token <API-key>
  3. Body: raw, JSON, {ā€œidā€:ā€œ<zone-ID>ā€, ā€œdurationā€:<seconds>}


1 Like

Can you believe the problem was that I didnā€™t have the curly braces around the JSON when I put it in the body of the messge. This is why it kept saying invalid container when i put it there. I had the dropdown as TEXT instead of JSON so I didnā€™t even notice that it was highlighting the issue.

THANK YOU! What a silly mistake. I couldnā€™t figure this outā€¦sometimes it just some outside eyes.

I had the inherited authorization, the global variables for zoneID, etc all rightā€¦ just some damn curly braces.

Here was my screen:

Glad you got it working, easy to make a mistake.

1 Like