REST architecture says that a resources state also should get a URL.
I am making a small application with very large queries. I would like to generate URLs with each query, but the queries are often larger than the URL character limit. I tried using URL shorteners but my URLss are too big even for them.
A lot of people online are suggesting using POST, but that is not idempotent. I really do not want to limit my query length and URLs should be able to identify an infinite amount of resources.
Is there a RESTful way to get around having very large URLs that does not involve POST requests?
To model this in a RESFtul way consider queries to be resources. They can be created, retrieved, and eventually deleted.
The client makes a
POST
request to aqueries
resource with the query details in the request body.This creates a new query resource. The server will respond:
The path segment
D560EC80-1006-11E5-80F6-75919330F945
will be an ID generated by the server for this specific query.Then the client requests the state of this query resource.
The server responds with the query result.
Later, the client can delete the query.
Or the sever can automatically delete the query after some time.