"Method Not Allowed" when http request with PUT, not GET

Hi,

I got stuck with “Method Not Allowed” when I send HTTPRequest with PUT to change the switch value. Here is my mappings for /switches and /switches/:command/:which.

mappings {

path("/switches") {
	action: [
    	GET: "listSwitches"
    ]
}
path("/switches/:command/:which") {
	action: [
    	PUT: "updateSwitches"
    ]
}

Now I send HTTP request:PUT, and get “Method Not Allowed” error.

$ curl -X PUT -H “Authorization: Bearer 17ff808d-9865-440a-8556-fcb707a28df2” https://graph.api.smartthings.com/api/smartapps/installations/9642fe9e-0914-445a-9c25-ec26c6cd5cef/switches/off/0
{“error”:true,“type”:“SmartAppException”,“message”:“Method Not Allowed”}

Interestingly, if I send HTTP request with GET, then the command works (that is, the switch value changed to On or Off), but I’ve got 500 internal error, like this:

		<dl class="error-details">
			<dt>Error</dt><dd>500: Internal Server Error</dd>
			<dt>URI</dt><dd>/api/smartapps/installations/9642fe9e-0914-445a-9c25-ec26c6cd5cef/switches/off/0</dd>
			<dt>Reference Id</dt><dd>8c85a657-2f07-45b0-938e-a799bfd6eb9a</dd>
			<dt>Date</dt><dd>Fri Oct 23 08:35:59 UTC 2015</dd>
		</dl>

What is the problem with my SmartApp? What’s wrong with PUT?

Seonman

1 Like