400 неверных запросов на Alexa AddOrUpdateReport с использованием JSON из документации - PullRequest
0 голосов
/ 23 сентября 2019

Моя проблема в основном описана в заголовке, но я добавлю немного больше деталей здесь.

Я пытаюсь предварительно отправить отчет об обновлении в центр событий Alexa для умных умных домов, однако это не удаетсяс ошибкой 400 Bad Request, и вот что отвечает сервер:

{
    "header": {
        "namespace": "System",
        "name": "Exception",
        "messageId": "a154410c-2364-4c5b-9028-accde5048e1e"
    },
    "payload": {
        "code": "INVALID_REQUEST_EXCEPTION",
        "description": "Event or endpoint is missing in the request."
    }
}

Я решил тогда проверить, был ли мой запрос неправильным, отправив тот, который можно найти в их документации, и яПолучение той же ошибки.

Это JSON, скопированный из документации Amazon (я только что заменил метаданные устройства и токен):

{
  "event": {
    "header": {
      "namespace": "Alexa.Discovery",
      "name": "AddOrUpdateReport",
      "payloadVersion": "3",
      "messageId": "5f8a426e-01e4-4cc9-8b79-65f8bd0fd8a4"
    },
    "payload": {
      "endpoints": [
        {
          "endpointId": "<unique ID of the endpoint>",
          "manufacturerName": "Sample Manufacturer",
          "description": "Smart Light by Sample Manufacturer",
          "friendlyName": "Kitchen Light",
          "additionalAttributes":  {
            "manufacturer" : "Sample Manufacturer",
            "model" : "Sample Model",
            "serialNumber": "<the serial number of the device>",
            "firmwareVersion" : "<the firmware version of the device>",
            "softwareVersion": "<the software version of the device>",
            "customIdentifier": "<your custom identifier for the device>"
          },
          "displayCategories": [
            "LIGHT"
          ],
          "capabilities": [
            {
              "type": "AlexaInterface",
              "interface": "Alexa.PowerController",
              "version": "3",
              "properties": {
                "supported": [
                  {
                    "name": "powerState"
                  }
                ],
                "proactivelyReported": true,
                "retrievable": true
              }
            },
            {
              "type": "AlexaInterface",
              "interface": "Alexa.BrightnessController",
              "version": "3",
              "properties": {
                "supported": [
                  {
                    "name": "brightness"
                  }
                ],
                "proactivelyReported": true,
                "retrievable": true
              }
            }
          ],
          "connections": [
          ],
          "cookie": {
          }
        }
      ],
      "scope": {
        "type": "BearerToken",
        "token": "access-token-from-Amazon"
      }
    }
  }
}

Что я не понимаю, так это почему он сообщаетчто event или endpoints отсутствуют, если они явно присутствуют и если этот JSON является тем, который они предоставляют в своей документации.

У кого-нибудь тоже есть эта проблема?

РЕДАКТИРОВАТЬ: вставка моей полезной нагрузки в соответствии с просьбой.

{
    "event": {
        "header": {
            "namespace": "Alexa.Discovery",
            "name": "AddOrUpdateReport",
            "payloadVersion": "3",
            "messageId": "132137185729061389"
        },
        "payload": {
            "endpoints": [
                {
                    "endpointId": "Rmxvb2RTZW5zb3JfMDE=",
                    "friendlyName": "Flood sensor",
                    "description": "Flood sensor",
                    "manufacturerName": "MyCompany",
                    "displayCategories": [
                        "ACTIVITY_TRIGGER"
                    ],
                    "cookie": {
                        "DeviceType": "FloodSensor"                 
                    },
                    "capabilities": [{
                            "interface": "Alexa",
                            "type": "AlexaInterface",
                            "version": "3"
                        },
                        {
                            "interface": "Alexa.EndpointHealth",
                            "type": "AlexaInterface",
                            "version": "3",
                            "properties": {
                                "supported": [{
                                    "name": "connectivity"
                                }],
                                "proactivelyReported": true,
                                "retrievable": true
                            }
                        }
                    ]
                }                
            ],
            "scope": {
                "type": "BearerToken",
                "token": "<redacted>"
            }
        }
    }
}
...