带有JSON结果的C#Http POST请求502错误的网关

时间:2019-04-03 08:48:54

标签: javascript c# asp.net

我正在从ASP.NET将一些JSON数据发布到AWS API Gateway,但仍然会收到502 Bad Gate错误。如果我使用邮递员或javascript打电话给他们,则没有问题。我已经启用了CORS。下面是我的代码:

private static readonly HttpClient client = new HttpClient();

string json = "{'centreId': 'spice_lib'}";

var httpRequestMessage = new HttpRequestMessage  
{
    Method = HttpMethod.Post,
    RequestUri = new Uri("https://v9j7bn4ia2.execute-api.ap-southeast-1.amazonaws.com/default/getQueueCount"),
    Headers = {
        { "x-api-key", "***********************************" }
    },
    Content = new StringContent(json, Encoding.UTF8, "application/json")
};

var result = await client.SendAsync(httpRequestMessage);

谢谢!

0 个答案:

没有答案