Reputation: 16677
Is there a way to pass an array of values to WCF WEB API service using a GET? I want to make the following call to my service:
http://localhost/myservice.com/projects/workspaceUsers?token=A3AD62998A7A463A9AD23D8F2937C92220120325072846&workspaceId=208&workspaceId=209
My web service function looks like:
[WebGet(UriTemplate = "workspaceUsers?token={token}&workspaceId={workspaceId}")]
public HttpResponseMessage<IEnumerable<WorkspaceUserReadOnlyChildData>> FetchWorkspaceUserList(string token, int workspaceId)
The thought was to just change int workspaceId to int[] workspaceId, but that leads to the following error:
The service operation 'FetchWorkspaceUserList' will never receive a value for the input parameter 'workspaceId' of type 'Int32[]'. Ensure that a request HttpOperationHandler has an output parameter with a type assignable to 'Int32[]'.
Is there any way to do this without doing something like passing a criteria object using a POST?
Thanks for the help!
Upvotes: 2
Views: 621
Reputation: 541
I think the easiest thing to do is just update to ASP.NET 4 WEB API. Since it operates off of the standard controller architecture, you can easily pass in arrays.
Upvotes: 1