2

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!

Darin Dimitrov
  • 1,023,142
  • 271
  • 3,287
  • 2,928
mattruma
  • 16,589
  • 32
  • 107
  • 171
  • Why don't you try comma seperated values, instead of int array. Had you been using ASP.Net MVC or the new Web API, you could have used ModelBinders – Chandermani Mar 26 '12 at 05:50

1 Answers1

1

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.

bkorzynski
  • 541
  • 1
  • 5
  • 15