Hi there,
I’m working on an API and now I’m adding an endpoint that acts as a proxy.
The idea is to have an integration set (which can be to any of the 3rd parties we support), with the client only having to pass a code string as the single endpoint argument.
Currently, the endpoint looks like this:
GET /v1/foobar/{id}/scan=code=<vendor code>
The code format gets validated (according to the integration set) and the appropriate 3rd party service is hit, returning an existing standardised resource (i.e. HTTP 200).
This mostly works, but there are two things I would like to avoid:
- depending on the 3rd party, clients might have to URL encode certain strings to be URL safe;
- we sometimes deal with long values (think a vCard + URL encoding);
Using POST instead of GET would prevent the client from having to worry about encoding values and data size, since data would be sent in the body, rather than as a URL parameter.
However, we’re not actually creating a resource, just retrieving an existing one.
Regarding resource retrieval, the spec says:
Data, including resources and relationships, can be fetched by sending a
GET
request to an endpoint.
Since it doesn’t say MUST, would using POST be valid according to the spec?
As for the payload, how would it look like, since we’re not actually creating a resource?
Would this be a case for meta
?
{
"meta": {
"code": "P)HcHXk3IQd?$%?bz/JpbfQ9#i:CEN"
}
}
How would we go about this, in order to keep it JSON:API compliant?
Thanks,
Q