REST API from Javascript - Invalid HTTP status code 405 - parse-platform

new Parse developer here looking for some help.
I'm trying to call the REST API from my app to log custom analytics, but for some reason the XMLHttpRequest I'm making fails with the error message:
XMLHttpRequest cannot load https://api.parse.com/1/events/marker. Invalid HTTP status code 405
Here is the code I am using to make the request:
xmlhttp.open("POST", "https://api.parse.com/1/events/marker", true);
xmlhttp.setRequestHeader("X-Parse-Application-Id","appidhere");
xmlhttp.setRequestHeader("X-Parse-REST-API-Key","apikeyhere");
xmlhttp.setRequestHeader("Content-Type","application/json");
xmlhttp.send('{"dimensions":{"action":"showDetails"}}');
This is the console output:
OPTIONS https://api.parse.com/1/events/marker (index):3639(anonymous function) (index):3639S.trigger main.js:15(anonymous function) VM625:31(anonymous function) VM623:11S.trigger main.js:15L.zc VM622:132L.nn VM622:132(anonymous function) main.js:13S.trigger main.js:15L.kl VM622:116(anonymous function) main.js:16
XMLHttpRequest cannot load https://api.parse.com/1/events/marker. Invalid HTTP status code 405`
The strangest thing though is that when I make the request using the curl example in the documentation it works perfectly fine. :/ Any ideas what I'm doing wrong? Hoping it's something simple that I'm overlooking. Thanks!

An HTTP 405 error is Method Not Allowed. The resource you're trying to hit does not accept the POST method.
Be certain that the resource you're trying to hit supports POST; if it doesn't, you'll have to change your XMLHttpRequest accordingly.

Related

Why Laravel reply 200 http code when MethodNotAllowedHttpException?

Why Laravel reply 200 http code when MethodNotAllowedHttpException?
I Would like to recieve a diferent code, like 500.
I consume laravel routes using angular or postman, and recieve 200 code and is dificult to deal with this.
Below one example:
This is not a error, but the usage of the dd() dump and die helper method. This will always return a 200.
Find all dd(); methods in your project and it should work and return a proper error code. But secondly due to that error being thrown, it could seem like your url is invalid and or not allowing POST calls.

XHR to same domain being blocked

I'm having a pretty weird problem with CORS on a webapp I'm trying to make
I'm using Servlets (Tomcat8.0) for the backend. It's a school project, so I can't use a framework
A GET request to http://localhost:8080/FileBox/dashboard
returns a JSON payload( plain json, not jsonp,which I could use, but its the same domain). I'm using ajax to make the XHR, but it's being blocked by chrome as CORS
Should this be happening, since I'm making the XHR from the same domain(host+port)
'localhost:8080/FileBox/dashboard.jsp'
to
'localhost:8080/FileBox/dashboard'
Please, and thank you for the help!
You aren't making a request to http://localhost:8080/FileBox/dashboard. The error message says you are making a cross-origin request using an unsupported scheme and that http is a supported scheme.
Presumably you have made the two mistakes of:
Getting the URL wrong
You should be using a relative URL:
/FileBox/dashboard
but are trying to use an absolute URL:
http://localhost:8080/FileBox/dashboard
but have typed it wrong and are actually requesting
localhost:8080/FileBox/dashboard
Not loading the page over HTTP to start with
Possibly by double clicking the file in your system file manager, you have bypassed your HTTP server and are loading something like file:///c:/users/you/yourproject/index.html
Combined with the previous mistake, you end up trying to request file:///c:/users/you/yourproject/localhost:8080/FileBox/dashboard, with Ajax and get a security violation.
Solution
Fix the URL to be a proper relative URL
Point your browser at http://localhost:8080 instead of double clicking files in your file manager

Getting ORA-29269 error while calling utl_http.begin_request

I have been trying to send request to a Web Service by issuing UTL_HTTP.BEGIN_REQUEST, but I get the error "ORA-29269: HTTP server error 500 - Server Error" if I call it like this:
v_request_pri := UTL_HTTP.BEGIN_REQUEST(v_ws_url_pri, 'POST', 'HTTP/1.1');
where v_ws_url_pri is the URL of the web service.
What surprises is, when I call UTL_HTTP.BEGIN_REQUEST with only the URL as the parameter (in which case, the second parameter is the 'GET' method by default, and the HTTP version is checked as latest), there is no error and the call is through.
Please if somebody may guide on the error, it would be a great help to me.
Thanks,
Gaurav

getting jsonp to work in asp.net api

having issues getting my jsonp to work with my client backbone script,pagenator keep gettgin invalid key error
having looked around people say its to to do with my service not return jsonp.
For example SyntaxError: invalid label, i've written a mvc4 web api service this is what it returns does it look right and also is there anything i need to add to my api to support jsonp ?
{
"odata.metadata":"http://test.test.uk/api/odata/$metadata#lnews","value":[
{
"ID":1,"title":"This is a test news artical","mainContent":"<p>\r\n\tthis is a test article</p>\r\n","featured":1,"visiblehomepage":1,"thedatetime":"2013-08-05T10:36:05.98","expireon":"2013-08-15T00:00:00","category":17,"embargo":null,"embargotime":"PT0S","embargodate":null,"customthumbnail":null,"news_layout":3,"LNBE":0,"LNBN":0,"LNBS":0,"LNBW":0,"LNWV":0,"LNWS":1,"LNDY":0,"LNSW":0,"LNSH":0,"LNCV":0
},{
"ID":2,"title":"This is a test article","mainContent":"<p>\r\n\twelcome to the best site in the world</p>\r\n","featured":1,"homepage":1,"thedatetime":"2013-08-05T10:42:54.763","expireon":"2013-08-22T00:00:00","category":null,"embargo":null,"embargotime":"PT0S","embargodate":null,"customthumbnail":"Water lilies.jpg","news_layout":4,"LNBE":1,"LNBN":1,"LNBS":1,"ff":1,"LNWV":1,"LNWS":1,"LNDY":1,"LNSW":1,"LNSH":1,"LNCV":1
}
]
}
Here is a JSONP URL:
http://odata.netflix.com/v2/Catalog/Genres?$format=json&$callback=?
Here is a diagram:
CLIENT SERVER
------ ------
Makes URL request Looks up function matching this URL param ($callback)
Executes asynchonously If found, executes function asynchonously
Returns from callback Returns data from server side as a function, or error
References
Learn By Example Guide for Select State.gov Data (SSD): JSONP

xhrPost : from an http view to an https url

using Dojo, is it possible to make an Ajax call using xhrPost from an HTTP view to a HTTPS url ?
The url must be HTTPS (as defined in Struts).
If I simply set "MyCommand" as the 'url' parameter of the xhrGet, I get a 302 error code.
If I transform "MyCommand" using javascript to something like "https://......./servlet/MyCommand" I see the following error in Firebug : "uncaught exception: Permission denied to call method XMLHttpRequest.open".
I'm stuck using both approaches, the only solution I found is to remove the "https" clause in the struts configuration file, and of course this is not a correct solution :)
Thanks for any help.
Best regards,
Nils
connection to https from http involves a different port of the target. This violates the same-origin policy which should be enforced by the browser to the running javascript code.
It should work with an iframe..
dojo.io.iframe encapsulates this behaviour for you
http://docs.dojocampus.org/dojo/io/iframe
If your server responds with a redirect to a non-ssl (correctly to same-origin) page you should be able to read the response (because the iframe is now in the same-origin).

Resources