Input an array in the Rest Web service

2019-08-03 07:05发布

问题:

I am creating a REST Web service in C# and need to take a list of item (e.g. activity list).

How can we take an array as input in Rest Web Service method? What would be final URI that will be created for such method?

回答1:

For what I know (I developed ReST services in Java with the Jersey library), the final URI is not affected by the type of the parameters you pass to the service. So the URI would be something like http://asite.com/service/activitylist.

Then for the implementation (in Java, maybe you could try to look for a REST implementation library in C#), in the client I would put my parameters (any type, arrays too) in a Form object (Jersey) and send it with my request. Then in my service I would access my parameters using the annotation @FormParam and finally process them normally in my service.

Hope it helps.



标签: .net wcf rest