C# 无法使用c从curl graph api获取json数据#

C# 无法使用c从curl graph api获取json数据#,c#,curl,libcurl,C#,Curl,Libcurl,我正在使用c#执行curl图api 我使用这个网站进行了curl查询,并将其转换为c#。 Api能够给出200个ok状态代码,但输出如下- { "extensions" : { "requestId" : "123" }, "data" : null, "errors" : [ { "message" : "Unable to process JSON", "extensions" : { "errorType" : "developer_e

我正在使用c#执行curl图api

我使用这个网站进行了curl查询,并将其转换为c#。

Api能够给出200个ok状态代码,但输出如下-

{
  "extensions" : {
    "requestId" : "123"
  },
  "data" : null,
  "errors" : [ {
    "message" : "Unable to process JSON",
    "extensions" : {
      "errorType" : "developer_error",
      "errorClass" : "VALIDATION"
    }
  } ]
}
result string conv: StatusCode: 200, ReasonPhrase: 'OK', Version: 1.1, Content: System.Net.Http.StreamContent, Headers:
{
  Connection: keep-alive
  Braintree-Version: 2016-10-07
  Strict-Transport-Security: max-age=31536000; includeSubDomains
  Vary: Braintree-Version
  X-Cache: Miss from cloudfront
  X-Amz-Cf-Pop: MIA3-C2
  X-Amz-Cf-Id: 111
  Date: Tue, 10 Sep 2019 16:13:54 GMT
  Via: 1.1 demo.cloudfront.net (CloudFront)
  Content-Length: 286
  Content-Type: application/json
}
C#代码-

我希望在输出中,我应该在数据json中得到一些东西


您确定您的查询是正确的吗?你能在线设置一些东西让我们测试吗?是的,查询是正确的,因为当我在curl命令中执行相同的命令时,它可能会工作,可能是一个
TryAddWithoutValidation
错误。它接受
TryAddWithoutValidation(String,IEnumerable)
但你有
TryAddWithoutValidation(String,String)
。没有代码示例很难判断。我使用了curl查询
https://curl.olsh.me/
并在c#代码上方使用。你能对任何卷曲样本做同样的处理吗?请引导梅苏尔,我会尽我最大的努力,但我今天可能无法到达。
    HttpClientHandler handler = new HttpClientHandler()
    {                
        UseProxy = false,
    };

    using (var httpClient = new HttpClient(handler))
    {
        using (var request = new HttpRequestMessage(new HttpMethod("POST"), "https://demo/graphql"))
        {
            // Prod token
            request.Headers.TryAddWithoutValidation("Authorization", "Basic abc");     
            request.Headers.TryAddWithoutValidation("Braintree-Version", "2019-01-01");
            request.Content = new StringContent("{\"query\": \"{ report { transactionLevelFees(date: \"2019-08-28\"){ url } } }\" }", Encoding.UTF8, "application/json");
            request.Content.Headers.ContentType = new MediaTypeHeaderValue("application/json");
            var response = await httpClient.SendAsync(request);

            // Get the response content.
            HttpContent responseContent = response.Content;
            response.Content.Headers.ContentType = new MediaTypeHeaderValue("application/json");
            // Get the stream of the content.
            using (var reader = new StreamReader(await responseContent.ReadAsStreamAsync()))
            {
                // Write the output.
                Console.WriteLine((await reader.ReadToEndAsync()));
            }
            Console.WriteLine($"result string conv: {response }");
        }
    }