I am trying to make a POST request from a javascript client to a four request API called addvenue. This is the endpoint API link.
But the server returns 405 - the method is not allowed. Here is the fragment causing the call
var postdata = {'oauth_token':$scope.access_token_foursquare, 'v':'20141217','name':'randomlisting', 'll':'44.3,37.2','m':'foursquare'}; var req = { method: 'POST', url: 'https://api.foursquare.com/v2/venues/add', headers: { 'content-type': 'application/x-www-form-urlencoded' }, data: postdata } $http(req).then(function(response){ console.log(response); });
Below is a request and response packet for the above call.
Remote Address:103.245.222.185:443 Request URL:https://api.foursquare.com/v2/venues/add Request Method:OPTIONS Status Code:405 Method Not Allowed **Request Headers** Accept:*/* Accept-Encoding:gzip, deflate, sdch Accept-Language:en-US,en;q=0.8 Access-Control-Request-Headers:accept, authorization, content-type Access-Control-Request-Method:POST Connection:keep-alive Host:api.foursquare.com Origin:http://localhost:9000 Referer:http://localhost:9000/foursquare User-Agent:Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.71 Safari/537.36 **Response Headers** Accept-Ranges:bytes Access-Control-Allow-Origin:* Connection:Keep-Alive Content-Length:90 Content-Type:application/json; charset=utf-8 Date:Wed, 17 Dec 2014 12:15:15 GMT Keep-Alive:timeout=10, max=50 Server:nginx Tracer-Time:1 Via:1.1 varnish X-Cache:MISS X-Cache-Hits:0 X-Served-By:cache-sn87-SIN
I also studied the CORS question. In my case, the server resolves all the origin, as seen from the response headers. I am amazed by this problem and cannot continue further.
Any help would be greatly appreciated. Thanks in advance.
source share