Randy7611273
Posts: 0
Joined: Sat Jun 27, 2015 7:03 pm

Method PUT is not allowed by Access-Control-Allow-Methods

Ever since the maintenance last weekend (Nov. 8), two areas in my apps which have worked for several months are now broken. The error messages are as follows:

"Failed to load resource: the server responded with a status of 400 (Bad Request)"

"Failed to load resource: Method PUT is not allowed by Access-Control-Allow-Methods."

"XMLHttpRequest cannot load https://api.appery.io/rest/1/db/colle.... Method PUT is not allowed by Access-Control-Allow-Methods."

Please help!

Illya Stepanov
Posts: 0
Joined: Mon Mar 18, 2013 8:48 am

Method PUT is not allowed by Access-Control-Allow-Methods

Hi Randy -

Could you please open browser console and select Network tab in it and show us Response payloads for all this service calls?

Randy7611273
Posts: 0
Joined: Sat Jun 27, 2015 7:03 pm

Method PUT is not allowed by Access-Control-Allow-Methods

Network Response:
{"code":"DBSU210","description":"Invalid object ID: '{_id}'"}

Request Header:
PUT /rest/1/db/collections/SetLists/%7B_id%7D HTTP/1.1
Host: api.appery.io
Connection: keep-alive
Content-Length: 87
Origin: http://appery.io
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.86 Safari/537.36
Content-Type: application/json
Accept: application/json, text/javascript, /; q=0.01
X-Appery-Session-Token: 61ea0c4f-edcb-4e27-8804-8cc81d6a6135
X-Appery-Database-Id: 5560cc00e4b0e70d35fcc974
Referer: http://appery.io/app/view/cf55b165-1d...
Accept-Encoding: gzip, deflate, sdch
Accept-Language: en-US,en;q=0.8

Response Header:
HTTP/1.1 400 Bad Request
Server: nginx
Date: Sat, 14 Nov 2015 14:24:40 GMT
Content-Type: application/json
Transfer-Encoding: chunked
Connection: keep-alive
Access-Control-Allow-Origin: http://appery.io
Access-Control-Allow-Credentials: true

Serhii Kulibaba
Posts: 150
Joined: Tue Aug 27, 2013 1:47 pm

Method PUT is not allowed by Access-Control-Allow-Methods

Hello Randy,

Could you also show us request data, which you send to the server?

Randy7611273
Posts: 0
Joined: Sat Jun 27, 2015 7:03 pm

Method PUT is not allowed by Access-Control-Allow-Methods

Image
Image

Where:
// was working before Nov 8
var thisVote = localStorage.getItem("id");
console.log(thisVote, "id");
return '{"_id": "'+thisVote+'"}';

Serhii Kulibaba
Posts: 150
Joined: Tue Aug 27, 2013 1:47 pm

Method PUT is not allowed by Access-Control-Allow-Methods

Please change:

prevar thisVote = localStorage.getItem("id");
console.log(thisVote, "id");
return '{"id": "'+thisVote+'"}';/pre
into:
preconsole.log(value, "id");
return '{"_id": "'+value+'"}';/pre
and add mapping's arrow:
http://prntscr.com/93j5ev

Randy7611273
Posts: 0
Joined: Sat Jun 27, 2015 7:03 pm

Method PUT is not allowed by Access-Control-Allow-Methods

I changed both the "Where" code and the mapping. Unfortunately, the error messages remain unchanged.

Serhii Kulibaba
Posts: 150
Joined: Tue Aug 27, 2013 1:47 pm

Method PUT is not allowed by Access-Control-Allow-Methods

Please send us screenshots with server request and response data from the network tab of the browser.

Serhii Kulibaba
Posts: 150
Joined: Tue Aug 27, 2013 1:47 pm

Method PUT is not allowed by Access-Control-Allow-Methods

You didn't set mapping to the request parameter "id" in that service, so Appery.io did'n change {id} into your value. Please add that mapping connection.

Return to “Issues”