我有类型POST的请求,资源如下所示: “stuff / user / {userid} / login”问题是,在添加用户id参数时,占位符不会被替换。
以下是代码:
RestRequest request = new RestRequest();
request.Resource = "stuff/user/{userid}/login";
request.Method = RestSharp.Method.POST;
request.AddParameter("userid", usuario, ParameterType.UrlSegment);
调试时,request.Resource =“stuff / user / {userid} / login”
发生了什么事?
答案 0 :(得分:2)
当请求执行时,它将替换参数
var client = new RestClient("http://example.com");
var result = client.Execute(request)
然后result.ResponseUri将是http://example.com/stuff/user/ [valueOfusuario] / login
/迈克尔