I am implementing an API endpoint that receives text through the request body, parses it, converts into structured data, and returns it as JSON in the response.
Since no existing resource is being retrieved, and no resource on the server is being created or modified, I am wondering what is the proper HTTP request type to use? It works with both POST and GET, but which one is technically proper?
Since no existing resource is being retrieved, and no resource on the server is being created or modified, I am wondering what is the proper HTTP request type to use? It works with both POST and GET, but which one is technically proper?
It is okay to use POST. The short version is that POST is the method token that we use when no other HTTP method is suitable.
GET is not suitable, because you are trying to include a semantically significant message body, and ....
... content received in a GET request has no generally defined semantics, cannot alter the meaning or target of the request, and might lead some implementations to reject the request and close the connection because of its potential as a request smuggling attack
The other possibility to consider is QUERY
This specification defines a new HTTP method, QUERY, as a safe, idempotent request method that can carry request content.
However, QUERY isn't a standard yet (the specification is still in draft status), and the method token is not yet registered. So you'll need to balance the tradeoff between it being fit for purpose and not necessarily being supported by all of the general purpose HTTP components that you are depending on.