user10058046
user10058046

Reputation:

Posting purely for use of the HTTP request body

This question is predicated on the assumption that a request body can be supplied as part of a GET request - but not recommended/in fitting with restful design, feel free to correct me if that's not the case before answering the question.

I have an endpoint (ASP .Net MVC, in case it matters), which responds with a FileResult, it is basically a 'Download Zip File' action. To build the zip file, it takes an arbitrary amount of ids (file ids), and does what it needs to do.

If part of the query string, this list of guids could grow quite rapidly, and may exceed the maximum length (putting aside how realistic this is for now).

This most definitely feels like a GET request to me, but I'd considered POST just so that I can leverage the use of the request body to dodge any limitations with the URL length restriction.

What is the restful way of circumventing this limitation?

Upvotes: 2

Views: 48

Answers (1)

Soumya Kanti
Soumya Kanti

Reputation: 1479

You can definitely use POST in this case. Both of your assumptions are correct. Request body in GET is not universally accepted (and I have seen proxies/security tools to drop such packets), and an arbitrarily long query string is also not possible.

Have you heard of Richardson Maturity Model? You can very well justify your API as Level 1 API.

Upvotes: 1

Related Questions