检索位置度量时出错

2024-04-26 01:18:41 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试在我的应用程序中检索位置度量。 我做这件事的方式是这样描述的here. 在googleoauth平台上,它的工作很好,但是当我在我的应用程序中这样做时,我的回答会出错:

{
  "error": {
    "code": 400, 
    "details": [
      {
        "@type": "type.googleapis.com/google.rpc.BadRequest", 
        "fieldViolations": [
          {
            "description": "Invalid JSON payload received. Unknown name \"basicRequest\": Cannot bind query parameter. 'basicRequest' is a message type. Parameters can only be bound to primitive types."
          }, 
          {
            "description": "Invalid JSON payload received. Unknown name \"encodingType\": Cannot bind query parameter. Field 'encodingType' could not be found in request message."
          }
        ]
      }
    ], 
    "message": "Invalid JSON payload received. Unknown name \"basicRequest\": Cannot bind query parameter. 'basicRequest' is a message type. Parameters can only be bound to primitive types.\nInvalid JSON payload received. Unknown name \"encodingType\": Cannot bind query parameter. Field 'encodingType' could not be found in request message.", 
    "status": "INVALID_ARGUMENT"
  }
}

我的职位要求:

data = json.load(open('request.json'))
url = 'https://mybusiness.googleapis.com/v3/accounts/1054012049xxxxxxxxxx/locations:reportInsights'
        e = google.post(url=url, data=data, headers={'Content-Type': 'application/json; charset=UTF-8', "Content-Length": 291})

以及带有请求正文的json文件:

{
  "locationNames": "accounts/105401204xxxxxxxx/locations/616918704xxxxxxxxxx",
  "basicRequest": {
     "metricRequests": {
               "metric": "ALL"
     },
    "timeRange": {
      "startTime": "2017-09-02T01:01:01.045123456Z",
      "endTime": "2017-10-02T23:59:59.045123456Z"
    }
  }
}

怎么了?你知道吗


Tags: namejsonmessageparameterbindtypebequery