For RESTful APIs, I need to use get for retrieving a list, however I want to pass some the following complex parameter as an input for the method.
{
"Filters": [
{
"FieldName": "sample string 1",
"FieldValue": "sample string 2"
},
{
"FieldName": "sample string 1",
"FieldValue": "sample string 2"
}
],
"SortField": "sample string 1",
"SortValue": 0,
"Page": 2,
"PageSize": 3
}
How the parameter will be passed since I cannot use the RequestBody in a Get method, and if I make it Post, it won't be RESTful.
Reading REST API using POST instead of GET and others, it doesn't seem that there is a canonical definition of Restful that forbids using POST for what you want.
In this case the rule could be "do what's best".
Further, since it appears that you own both the host and client ends of the process, there's not much reason to avoid POST.
Fundamentally, there's no simple way to incorporate serialized json in a URL, which is what GET would need.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With