4

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?

Peter Frisch
  • 53
  • 1
  • 1
  • 5
  • What do your nginx logs show? Is there actually just one POST request attempt, or it is a POST followed with GET? Maybe there is a 302 in response to the first POST? – Roman Puchkovskiy Feb 16 '18 at 18:26
  • You seem to be right. There is a POST request and a GET request. Where did that come from? – Peter Frisch Feb 17 '18 at 09:17
  • Just a guess: is there some security framework like Spring Security that considers the original POST unauthenticated and makes a redirect to a login page? If so, you need to make your request authenticated or configure the security framework to allow non-authenticated requests for this endpoint. – Roman Puchkovskiy Feb 17 '18 at 10:55
  • 3
    I think I found the reason, but I'm not completely sure where the GET came from. I configured my nginx to forward all HTTP requests to HTTPS. My original POST request was done by HTTP, so I got a response 301, but here my networking knowledge ends ... who sent the GET request that failed on my Wildfly? – Peter Frisch Feb 17 '18 at 20:48
  • 2
    Just a guess again: a user agent (Postman in this case?) may redirect using GET request as a reaction to 301, even if the initial request was POST. – Roman Puchkovskiy Feb 18 '18 at 11:05
  • Hmm ... we probably will never know ;) But thanks for your help. I really appreciate it! – Peter Frisch Feb 19 '18 at 06:19
  • Just to add. I had the same issue, but @RomanPuchkovskiy suggestion about redirection was the key to solving it – Lennert De Feyter Sep 02 '20 at 07:20

1 Answers1

1

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).

geigea84
  • 11
  • 1