How to use RestSharp for non standard url containing symbols like = and ::?

StackOverflow https://stackoverflow.com/questions/21769398

  •  11-10-2022
  •  | 
  •  

سؤال

I have to call the following URL using RestSharp. Some part of the uri are not standard. How can I get to use them in

The url is the following but without the white space: http:// mysite.com/api/v2.php?method = information :: method&token=b&target_id=0

I've tried something like this but RestSharp is not calling the URL I was expecting to call.

var client2 = new RestClient("http:// mysite.com/api/v2.php");
var request = new RestRequest("method=information::method", Method.GET);
request.AddParameter("token", authenticationToken);
request.AddParameter("target_id", targetId);
هل كانت مفيدة؟

المحلول

You don't mention what url your code actually calls, but I guess that your method is parsed as a file/path, and not a parameter.

var client = new RestClient("http:// mysite.com/api/");
var request = new RestRequest("v2.php", Method.GET);
request.AddParameter("method", "information::method");
request.AddParameter("token", authenticationToken);
request.AddParameter("target_id", targetId);
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top