Sunny
Sunny

Reputation: 4809

How to write method having many parameters in REST webservice

I need to develop a web method that has many parameters. In REST, I understand a webservice has its own significance by attaching itself to particular entity and HttpVerb determines operation type.

This webmethod cannot be associated with an entity, it just calls a stored procedure and returns data, so I assume it only has only a GET method. But it has too many parameters to be fit into a URL. So, do I need to consider using POST method instead of GET.

Upvotes: 3

Views: 450

Answers (1)

Kalpers
Kalpers

Reputation: 658

It wouldn't really pass as 100% true to REST but you can have one web method that you call that looks at query string part of the url to get the additional parameters.

You would have a web method with a route of '/GetData'.

domain.com/GetData?Parameters=firstParm=1^secondParm=info^thirdParm=test

then in the web method, you would check the query string for Parameters and then split the string by the '^' symbol.

or

domain.com/GetData?firstParm=1&secondParm=info&thirdParm=test

this you would have to do a query string for each parameter.

Upvotes: 1

Related Questions