Skip to content Skip to sidebar Skip to footer

Response From Pre-flight Failing With Status 405

I'll start by saying I'm a bit of a newb when it comes to Javascript/React. I am attempting to communicate with my WCF endpoint server but I can’t seem to send any POST messages

Solution 1:

I have found a solution, I'm not sure if it's the most elegant solution but it does work.

Basically I have an endpoint that the call should be directed too, but it only accepts POST requests, so I have added an OPTIONS endpoint with an empty method and it all appears to work now.

So I now have:

[ServiceContract]
public interface IPlatform
{
    [OperationContract]
    [WebInvoke(UriTemplate = "testbuyTicket")]
    TicketResponse TestBuyTicket(PurchaseRequest purchaseRequest);

    [OperationContract]
    [WebInvoke(UriTemplate = "testbuyTicket", Method = "OPTIONS")]
    TicketResponse TestBuyTicketOptions(PurchaseRequest purchaseRequest);
}

Doing this allows the server to respond to the OPTIONS call and then the POST call.

Thanks everyone for your assistance.

Big shoutout to @demas for the idea, see post Response for preflight has invalid HTTP status code 405 for more info


Solution 2:

Like @charlietfl says, this doesn't appear to be a CORS issue, since you seem to be returning the headers OK (per the screenshot).

My guess is that your web server (Apache or whatever) doesn't allow OPTIONS requests - many only allow GET/POST/HEAD by default.

Probably a simple web server setting...


Post a Comment for "Response From Pre-flight Failing With Status 405"