My app has an API endpoint GET /sessions/{id}
which gets info about a session. This endpoint returns a lot of data, so we allow passing JSON in the request body to filter what fields etc. are requested. I know GET requests should not include request body, so I am trying to convert it to POST but not sure what to call the endpoint now:
POST /sessions/{id}
(but this looks like it's modifying the session, which it doesn't do)POST /session_info/{id}
(to make it clear that we are just querying info)POST /session/{id}/info
Example use:
GET /sessions/42
request body:
{'participants': ['jsmith', 'bjones'], 'participant_fields': ['dob', 'zip']}`
response:
{
'id': 42,
'date': '2022-08-29',
'room': 15,
'participants': [
{'id': 'jsmith', 'dob': '1985-01-06', 'zip': 04843},
...
],
...
}
(participants
and participant_fields
are optional; if omitted it will return all data about all participants.)
I know GET requests should not include request body, so I am trying to convert it to POST but not sure what to call the endpoint now:
POST /sessions/{id}
(but this looks like it's modifying the session, which it doesn't do)POST /session_info/{id}
(to make it clear that we are just querying info)POST /session/{id}/info
(I know the filter params could be encoded as query string but I just think it's easier for my users to use JSON.)
Any advice?