Question

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!

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top