Restsharp不用urlSegment替换请求占位符

时间:2014-02-05 21:58:00

标签: c# rest restsharp

我有类型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”

发生了什么事?

1 个答案:

答案 0 :(得分:2)

当请求执行时,它将替换参数

var client = new RestClient("http://example.com");
var result = client.Execute(request)

然后result.ResponseUri将是http://example.com/stuff/user/ [valueOfusuario] / login

/迈克尔