3

I'm trying to access a Google Protocol RPC API with jQuery like this:

jQuery.ajax({
    url: some_url,
    type: "POST",
    data       : some_params,
    contentType: "application/json; charset=utf-8",
    dataType   : "json",
    success    : function (data) {
            console.log(data);
        },
    error      : function (xhr, status, errorThrown) {
        console.log(xhr);
    }
});

But I only get the following error message:

XMLHttpRequest cannot load https://*****. Response for preflight has invalid HTTP status code 400 

How can I return an OPTIONSmethod in ProtoRPC, that I don't get this error anymore?

SimonR
  • 95
  • 9
  • This error sometimes occurs because the receiver was expecting a GET instead of a POST – David Miró Apr 19 '16 at 13:55
  • I should mention, that the API works perfectly when called via CURL or Postman or similar tools. – SimonR Apr 19 '16 at 14:03
  • I know little curl, but ... please, could you paste a example with curl?.... It may be a good clue – David Miró Apr 19 '16 at 14:06
  • curl -X POST -H "Content-Type: application/json" -d some_params ' "the url" – SimonR Apr 19 '16 at 14:22
  • 1
    I really don't think, that the post request itself is the problem. My guess is, that, as Google Chrome is doing a preflight request via OPTIONS, this is the problem – SimonR Apr 19 '16 at 14:25

0 Answers0