Can GET and PUT using REST in curl, but not from Chrome client


#1

I can PUT and GET just fine using curl, however, I need to be able to do them from a browser REST client in Chrome for a remote control project I’m working on for iRule. I downloaded a REST client for Chrome and it’s working fine for GET, however, I can’t seem to get it to work for PUT’s.

Has anyone had any success doing PUT’s from a browser?

I’m using target_tempurature_f and I think my real problem is I don’t know how to set a value for it from a web browser REST client.

https://developer-api.nest.com/devices/thermostats/NgTlrU5iw.../?auth=c.8YX4
I add Content-Type as a header and application/json as a value for that header and GET returns the json response just fine.

If I add target_temerature_f to the URL as so:
https://developer-api.nest.com/devices/thermostats/NgTlrU5iw.../target_temperature_f?auth=c.8YX4

it returns the target temp with a get. I can not figure out how to set it with a PUT. I’ve tried everything. I just keep getting invalid content sent. My issue is I don’t know how to set data in the http request. Any ideas?

This is the curl PUT that works:

curl -L -X PUT “https://developer-api.nest.com/devices/thermostats/NgTlrU5iw.../target_temperature_f?auth=c.8YX…” -H “Content-Type: application/json” -d “72”

Thanks,
Craig


#3

The PUT works the same regardless of source so its most likely an issue with your front end code. Can you post the code you’re using to form and send the HTTP PUT?


#4

That’s just it. I can’t write code, per se. I need to form an HTTP PUT that can be entered from a REST client. So, my options are headers, and the URI. I’m trying to figure out a way to form the request but I’ve been unsuccessful. GET works, no issue. But trying to set a value is something I just don’t know how to do.

URI:
https://developer-api.nest.com/devices/thermostats/NgTlr.../target_temperature_f?auth=c.8YX

I can add headers:

Header Name Header Value

Content-Type application/json
data 75

The above header(s) will be added to the next request.

The form looks like above. This was one attempt… I’ve made many variations. I’m not sure how to do this with what I have. I’m limited by the product I’m trying to use which is iRule.

Thanks,
Craig


#5

What REST client are you using? or what are you building your forms in?


#6

YARK on Chrome. I’ve also tried ARC. It’s very basic. All I want to do is issue that curl command but I’m lacking the equivalent of the -d parameter from the client.

Is there a way to set the temperature from a browser? If there were a URI I could put together and send, that would be fine.

BTW: this is the request that gets generated from the client:

{
  "method": "PUT",
  "transformRequest": [
    null
  ],
  "transformResponse": [
    null
  ],
  "url": "https://developer-api.nest.com/devices/thermostats/NgTlr.../target_temperature_f?auth=c.8YX4...",
  "headers": {
    "data": "75",
    "Accept": "application/json, text/plain, */*"
  },
  "timeout": {}
}

Thanks for taking the time on this. I really appreciate it. I know that data header is silly, I’m just grasping at straws now. :slight_smile:


#7

Not super familiar with ARC but there are a few things to note. -d is the body which probably wont work if its in the header.

You also have your type as json and text/plain which should just be json.

Best bet is to find some docs on YARK on sending POST commands or asking in Stack Overflow. It feels like you’re so close!


#8

I’m just trying to get the -d in there. That’s my issue. I don’t know how?