JSON:无法解组字符串

问题描述 投票:-1回答:1

我正在尝试使用Rest API,但是当我查询时,收到以下我不理解的错误,我试图在此处查看类似的问题,但它们是非常特殊的情况。这是我使用的代码

$oAuth2TokenUrl = "https://api.cloudflare.com/client/v4/graphql"
$accessKey = '1234'

$Cloudflare_Oauth_Header = @{
    "X-AUTH-EMAIL" = "bryan";
    "X-AUTH-KEY" = "$accessKey";
    "Content-type" = "application/json"
}

$query = '\"query\": \"{
  viewer {
zones(filter: {zoneTag: \"1234\"}) {
  httpRequests1mGroups(orderBy: [datetimeMinute_ASC], limit: 1000, filter: {datetime_geq: \"2020-05-07T10:00:00Z\", datetime_lt: \"2020-05-07T10:10:00Z\"}) {
    dimensions {
      datetimeMinute
    }
    sum {
      browserMap {
        pageViews
        uaBrowserFamily
      }
    }
    uniq {
      uniques
    }
  }
}
  }
    } \"' | ConvertTo-Json    

$Cloudflare_zone = Invoke-RestMethod -Uri $oAuth2TokenUrl -Method POST -Headers $Cloudflare_Oauth_Header -Body $query -ContentType 'application/json'

所以一旦我检查了$Cloudflare_zone的内容,就会打印出以下内容>>

{@{message=failed to recognize JSON request: 'json: cannot unmarshal string into Go value of type graphql.httpPostBody'; path=; extensions=}}

我正在尝试使用Rest API,但是当我查询时,收到以下我不理解的错误,我试图在此处查看类似的问题,但它们是非常特殊的情况。这是...

json powershell graphql
1个回答
0
投票

错误显示“” json:无法将字符串解组为graphql.httpPostBody类型的Go值“]。

© www.soinside.com 2019 - 2024. All rights reserved.