Post WebApi客户端。邮差

Post WebApi客户端。邮差,post,asp.net-web-api2,Post,Asp.net Web Api2,我有一些奇怪的问题。我正在使用Microsoft.AspNet.WebApi.Client.5.2.3for API的简单.NET客户端。我想将一些数据发布到API。我正在为它使用PostAsJsonAsync方法 using (var client = new HttpClient()) { var adress = new Uri("http://localhost:28906/v1/things?access_token=SOMET

我有一些奇怪的问题。我正在使用
Microsoft.AspNet.WebApi.Client.5.2.3
for API的简单.NET客户端。我想将一些数据发布到API。我正在为它使用
PostAsJsonAsync
方法

        using (var client = new HttpClient())
        {

            var adress = new Uri("http://localhost:28906/v1/things?access_token=SOMETOKEN");
            var result = await client.PostAsJsonAsync(adress, new ThingModel() { Name = "test"});

        }

当我发送请求时,我的uri从
转换而来http://localhost:28906/v1/things?access_token=SOMETOKEN“
”http://localhost:28906/v1/things/?access_token=SOMETOKEN“
(“/”插入在“?”之前)。这样的请求就错了。我怎样才能克服这个问题?事实上,如何传递查询字符串和json正文?

仅用于测试,不要使用
Uri
,并尝试将字符串直接放入
PostAsJsonAsync
方法中,然后查看它是否仍然在所包含的
之前包含尾部斜杠。很奇怪,我为您输入的代码创建了一些单元测试,它们通过了。当我检查发送的请求时,没有添加尾随斜杠。我无法重现您的特定问题。仅用于测试,请不要使用
Uri
,并尝试将字符串直接放入
PostAsJsonAsync
方法中,然后查看它是否仍包含它包含的
之前的尾随斜杠。很奇怪,我为您输入的代码创建了一些单元测试,它们通过了。当我检查发送的请求时,没有添加尾随斜杠。我无法复制您的特定问题。