Help me settle an internal question.
We have an endpoint which we all agree should be a GET, because all it's doing is calling a stored proc and returning a set of data. However, there is a set of filters that we need to pass to the endpoint. Below is an example of what the filers might look like if all of the filter options are passed:
{
"DistributorCode":"6065",
"Model":"123-xyz",
"Serial":"654654065",
"CurrentSMR":"11350.47",
"SoldbyDistributor":"",
"ServiceDistributor":"",
"LatestSMRDate":"02/12/2020",
"Coverage":"",
"Customer":"",
"CoverageExpirayDate":"",
"SortBy":{
"name" :"serial",
"order":"asc"
},
"select":["eh","wt","fc"]
}
We could just pass in this json string as a querystring parameter in the GET call, or we could have each of them be their own parameter (although SortBy might get tricky).
But some are concerned that this will make the URL too long, and we will risk running into max query string length
errors. So, they want to make the call a POST instead. If it were a POST call, then it would require both an object in the body and at least one QS param (&code=) which is non-negotiable (it must be there.)
So we have two options (that I can think of):
Make it a GET call with a potentially very long URL due to the parameters.
1a) each filter is its own parameter
1b) the list of filters is a json string in it's own parameter
Make it a POST call that requires both QS parameters and a json object in the Body
Which would you do, and why?
Thanks!
Can I pass a body with a GET call.
That's not what I am asking here.