Reputation: 1281
I have the following two endpoints served by a single Azure Function:
Neither of these endpoints accept a request body and in both cases the Function code will return a 400 response if a body is found in the request. I have tested and confirmed this functionality when calling the Function directly.
When I setup the Function as a backend in API Management and start calling it via API Management I see different behaviour. The PUT endpoint still returns a 400 response while the GET endpoint returns a 200 response.
I suspect that API Management is stripping the request body of the GET request before passing it onto the Azure Function backend. If this is indeed the case then I am looking for some documentation that describes this behaviour.
I know that GET requests typically should not contain a request body. This question is not about RESTful APIs, rather the behaviour of API Management.
Upvotes: 0
Views: 1676
Reputation: 4286
That is correct, this is by design, APIM cannot bypass RFC compliance requirements so if you send a body with a Get method, APIM will create a new request to the backend and send it without the body.
Upvotes: 0
Reputation: 15754
Yes, I think the cause is what you mentioned in your question: API Management is stripping the request body of the GET request before passing it onto the Azure Function backend
.
For this feature, I can't find official document about it. But we need to know, the Get method rest api should not contain the request body(as you mentioned). In postman, we can request api in Get method with request body. But in some other utils, they don't allow users to add request body when request api in Get method (As far as I know, it is also not allowed in older versions of Postman).
And by the way, if we test the APIM api on azure portal, it also doesn't allow us to add request body if the method is "Get". So I think APIM will strip the request body of Get request before passing it onto Azure Function backend.
Upvotes: 1