我有一个卷曲请求,如下所示:
curl -i -XPOST 'http://my_url:port/write?db=myDb' -u user:xxxxx --data-binary 'FieldName,host=M.233 value=52.666 timestamp'
我试图使用HttpClient发布此请求。我不确定我应该怎么称呼它。这就是我试图做的事情:
public async void TestHttpClient()
{
var client = new HttpClient();
var credentials = Encoding.ASCII.GetBytes("user:xxxxx");
var header = new AuthenticationHeaderValue("Basic", Convert.ToBase64String(credentials));
client.DefaultRequestHeaders.Authorization = header;
client.BaseAddress = new Uri("http://my_url:port/write?db=myDb");
var result = await client.PostAsync(..);
}
我应该为PostAsync()编写哪些参数?
如何将--data-binary
和FieldName,host=M.233 value=52.666 timestamp
从curl转换为HttpClient?
答案 0 :(得分:2)
我的解决方案是:
swagger-maven-plugin