我有https://www.bookstone.com/api/rest/bookshop/gettotal?products=[{\"PRICE\":39.95,\"RECIPIENT\":{\"ZIPCODE\":\"11779\"},\"CODE\":\"F1-509\"}]
这个https在Postman中工作得很好,我得到了结果。
{
"SERVICECHARGE": 14.99,
"SUBTOTAL": 39.95,
"TAX": 0,
"ORDERTOTAL": 54.94,
"ORDERNO": 0,
}
但是在视觉工作室中却不起作用。
var url = "https://www.bookstone.com/api/rest/bookshop/gettotal?products=[{\"PRICE\":39.95,\"RECIPIENT\":{\"ZIPCODE\":\"11779\"},\"CODE\":\"F1-509\"}]";
var response = await client.GetAsync(url);
有什么想法吗?
答案 0 :(得分:0)
幸运的是,我找到了将数组参数转换为URL中查询参数的解决方案。
[{"PRICE":98.5,"RECIPIENT":{"ZIPCODE":"12345"},"CODE":"abc"}]
var queryString = JsonConvert.SerializeObject(object);
//convert to &
//%5b%7b%22PRICE%22%3a39.95%2c%22RECIPIENT%22%3a%7b%22ZIPCODE%22%3a%2211779%2 2%7d%2c%22CODE%22%3a%22F1-509%22%7d%5d
var uri = WebUtility.UrlEncode(queryString);