Peter Frisch
Peter Frisch

Reputation: 63

"No resource method found for GET, return 405 with Allow header" but doing a POST request

I'm having a problem accessing my rest endpoint. I'm trying to do a login with a POST request, but keep getting

ERROR [org.jboss.resteasy.resteasy_jaxrs.i18n] (default task-36) RESTEASY002010: Failed to execute: javax.ws.rs.NotAllowedException: RESTEASY003650: No resource method found for GET, return 405 with Allow header

I'm using Postman for testing, so I'm pretty sure I actually create a POST request and not a GET request.

On the server I use a CORS filter and looking at the header in the response, I think it's working:

Access-Control-Allow-Credentials →true
Access-Control-Allow-Headers →origin, content-type, accept, authorization
Access-Control-Allow-Methods →GET, POST, PUT, DELETE, OPTIONS, HEAD
Access-Control-Allow-Origin →*
Access-Control-Max-Age →1209600
Allow →POST, OPTIONS
Allow →GET, POST, PUT, DELETE, OPTIONS, HEAD
Connection →keep-alive
Content-Length →0
Date →Fri, 16 Feb 2018 17:47:04 GMT
Server →nginx/1.10.3 (Ubuntu)
X-Powered-By →Undertow/1

(Yes, I'm aware it's not the safest idea to allow ALL origins, and virtually eternity for max age. But I can restrict this further, when I worked around my current problem).

As for the server setup: I'm running Wildfly 11.0.0 Alpha1 and Nginx for an Angular5 Application that ultimately is supposed to do the login.

Any suggestions where to look for the cause of this problem?

Upvotes: 5

Views: 24536

Answers (1)

geigea84
geigea84

Reputation: 81

I ran into the exact same error when I updated one of my GET requests to a POST request. I failed to update the endpoint in Postman and then tried to run it, and that's when the error was thrown. Updating the request type in Postman to match my code cleared the error. Double check that your request types match, and do be sure to click save (Postman can get finicky).

Upvotes: 2

Related Questions