我在下面编写代码来调用第三方API但返回错误:参数错误。我在Postman中测试它可以返回响应JSON结果。任何人都可以帮助我做错了。
namespace DemoApps
{
class Program
{
static HttpClient httpClient = new HttpClient();
class P
{
public string language_id { get; set; }
public string order_no { get; set; }
public string token { get; set; }
}
static void Main(string[] args)
{
string url = "http://medpro.vizzhost.com/linsy/eshop/admin/index.php?route=api/order/getByNo";
string paramStr = Newtonsoft.Json.JsonConvert.SerializeObject(new P() {
language_id = "1",
order_no = "1707170018",
token = "6b887489372f483792d490f5bc8104ef"
});
HttpContent content = new StringContent(paramStr, System.Text.Encoding.UTF8);
content.Headers.ContentType = new MediaTypeHeaderValue("application/json");
var response = httpClient.PostAsync(url, content)
.Result.Content.ReadAsStringAsync();
Console.WriteLine(response.Result.ToString());
Console.ReadKey();
}
}
}