6

When I use code below from REST Sharp I am not able to pass listOfSelectedTicketsIds it always null.

Request of Rest Sharp .net Client

 var _stDeveloperApi = new RestClient("http://127.0.0.1/");
 var url = string.Format("api/v1/SignalR/MultiClickMode");
 var listOfSelectedTicketsIds = new List<int> { 2, 3 };
 var request = new RestRequest(url, Method.GET);
 request.AddParameter("listOfSelectedTicketsIds", listOfSelectedTicketsIds, ParameterType.GetOrPost);
 var response = _stDeveloperApi.Execute(request);

Web API Method

[HttpGet]
 public HttpResponseMessage MultiClickMode(List<int> listOfSelectedTicketsIds)
 { 
 var response = new HttpResponseMessage();
 try
 {
 }
 catch (Exception ex)
 {
 response = Request.CreateResponse(HttpStatusCode.InternalServerError);
 }
 return response;
 }
asked Jan 21, 2014 at 23:38

1 Answer 1

12

Change your client code like this.

var _stDeveloperApi = new RestClient("http://127.0.0.1/");
var url = string.Format("api/v1/SignalR/MultiClickMode");
var listOfSelectedTicketsIds = new List<int> { 2, 3 };
var request = new RestRequest(url, Method.GET);
listOfSelectedTicketsIds.ForEach(t => 
 request.AddParameter(
 "listOfSelectedTicketsIds", t, ParameterType.GetOrPost));
var response = _stDeveloperApi.Execute(request);

Change the web API action method signature like this.

public HttpResponseMessage MultiClickMode(
 [FromUri]List<int> listOfSelectedTicketsIds)
answered Jan 22, 2014 at 7:28

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.