Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Apigateway

{"message": the current request is matched to defined url template\"/users/service\"  but its http method is not allowed ,code :405}

Tried implementing api gateway with cloud run all the methods are working Post/get but only one particular (post) is not working I'm clueless please help me out on this issue

Solved Solved
0 2 2,269
1 ACCEPTED SOLUTION

Hi @Shaiknagulmeera,

Welcome to Google Cloud Community!

There are a few possible reasons why you might be encountering an HTTP 405 error when trying to send a POST request to an API Gateway endpoint that is backed by Cloud Run:
  1. Make sure that you have properly configured the API Gateway to allow POST requests for he particular endpoint that you are trying to access. You can do this by editing the "Method Request" settings for that endpoint in the API Gateway console.
  2. Make sure that the Cloud Run service that you have deployed is able to handle POST requests. You can do this by checking the service's code to ensure that it has a handler for POST requests.
  3. If you are sending a payload with your POST request, make sure that it is properly formatted and meets any requirements that the Cloud Run service has for request payloads.
  4. If you are using a custom domain for your API Gateway endpoint, make sure that it is properly configured to route traffic to the API Gateway.

Thank you

 

View solution in original post

2 REPLIES 2

Hi @Shaiknagulmeera,

Welcome to Google Cloud Community!

There are a few possible reasons why you might be encountering an HTTP 405 error when trying to send a POST request to an API Gateway endpoint that is backed by Cloud Run:
  1. Make sure that you have properly configured the API Gateway to allow POST requests for he particular endpoint that you are trying to access. You can do this by editing the "Method Request" settings for that endpoint in the API Gateway console.
  2. Make sure that the Cloud Run service that you have deployed is able to handle POST requests. You can do this by checking the service's code to ensure that it has a handler for POST requests.
  3. If you are sending a payload with your POST request, make sure that it is properly formatted and meets any requirements that the Cloud Run service has for request payloads.
  4. If you are using a custom domain for your API Gateway endpoint, make sure that it is properly configured to route traffic to the API Gateway.

Thank you

 

Dear,

I am facing the same error as the original poster: HTTP error 405, 

"message": "The current request is matched to the defined url template \"..." but its http method is not allowed" when invoking my newly created POST endpoint.
Initially I was happy to find your answer: this is a new endpoint, and I indeed never explicitly enabled POST method for it, so I was expecting to follow advice #1 from your reply. Unfortunately the mentioned setting "Method request" is not found in the API Gateway console. Is this gone due to GUI restructuring?