question

Raghav Gautam avatar image
Raghav Gautam asked

Alexa Event gateway returns 400 BAD REQUEST on AddorUpdateReport

I'm trying to send async report to alexa event gateway but receiving 400 error.

Can't figure out whats wrong with the JSON when I have literally copied the exact template from the official docs

I'm even sending Authorization header with the oauth token

{
    "event": {
        "header": {
            "namespace": "Alexa.Discovery",
            "name": "AddOrUpdateReport",
            "payloadVersion": "3",
            "messageId": "abc-123-def-456"
        },
        "payload": {
            "endpoints": [
                {
                    "endpointId": "appliance-001",
                    "friendlyName": "Living Room Light",
                    "description": "COB Light",
                    "manufacturerName": "dummy",
                    "displayCategories": [
                        "LIGHT"
                    ],
                    "capabilities": [
                        {
                            "type": "AlexaInterface",
                            "interface": "Alexa.ColorTemperatureController",
                            "version": "3",
                            "properties": {
                                "supported": [
                                    {
                                        "name": "colorTemperatureInKelvin"
                                    }
                                ],
                                "proactivelyReported": "true",
                                "retrievable": "true"
                            }
                        },
                        {
                            "type": "AlexaInterface",
                            "interface": "Alexa.EndpointHealth",
                            "version": "3",
                            "properties": {
                                "supported": [
                                    {
                                        "name": "connectivity"
                                    }
                                ],
                                "proactivelyReported": "true",
                                "retrievable": "true"
                            }
                        },
                        {
                            "type": "AlexaInterface",
                            "interface": "Alexa",
                            "version": "3"
                        },
                        {
                            "type": "AlexaInterface",
                            "interface": "Alexa.ColorController",
                            "version": "3",
                            "properties": {
                                "supported": [
                                    {
                                        "name": "color"
                                    }
                                ],
                                "proactivelyReported": "true",
                                "retrievable": "true"
                            }
                        },
                        {
                            "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"
                            }
                        }
                    ],
                },
                {
                    "endpointId": "appliance-002",
                    "friendlyName": "Bedroom Panel",
                    "description": "Touch Based Bedroom Panel",
                    "manufacturerName": "Dummy",
                    "displayCategories": [
                        "SWITCH"
                    ],
                    "capabilities": [
                        {
                            "type": "AlexaInterface",
                            "interface": "Alexa.EndpointHealth",
                            "version": "3",
                            "properties": {
                                "supported": [
                                    {
                                        "name": "connectivity"
                                    }
                                ],
                                "proactivelyReported": "true",
                                "retrievable": "true"
                            }
                        },
                        {
                            "type": "AlexaInterface",
                            "interface": "Alexa",
                            "version": "3"
                        },
                        {
                            "type": "AlexaInterface",
                            "interface": "Alexa.PowerController",
                            "version": "3",
                            "properties": {
                                "supported": [
                                    {
                                        "name": "powerState"
                                    }
                                ],
                                "proactivelyReported": "true",
                                "retrievable": "true"
                            }
                        },
                    ]
                },
            ],
            "scope": {
                "type": "BearerToken",
                "token": "FdeTi6Q2YJobuRU0dToXU2EwFRKHrW"
            }
        }
    }
}
alexa smart home
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Raphael avatar image
Raphael answered

I think it is just broken right now. I also get a 400 for messages which were working before.

10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Amazon_Bernardo Bezerra avatar image
Amazon_Bernardo Bezerra answered

Hello @Raghav Gautam and thanks for your message.

Are you still facing this issue?

The JSON you copied from the documentation is supposed to be just an example. It is not necessarily a working example.

Your endpoint should be sending the message.

Regards,
Barry

10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Raghav Gautam avatar image
Raghav Gautam answered

hey @barry@amazon , Thanks for the response but still cant get it to work

I think its obvious that my server is hitting the API.
I have confirmed that the token is correct and I had sent the same endpoint even in the discovery.

Just out of curiosity - is there any special reason why you guys don't send back a detailed responses with the detailed error what is happening.
I had a tough time even getting the TLS to work which was due to certificate chain incorrect and your API response could have easily pointed that out to me and save a couple of weeks.


1 comment
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Hello @Raghav Gautam and sorry for the delayed reply.

Can you please share the JSON being sent by your endpoint?

Regards,
Barry

0 Likes 0 ·
newuser-e65d3160-ec56-48d1-ad6c-1f30e53e33ab avatar image
newuser-e65d3160-ec56-48d1-ad6c-1f30e53e33ab answered

I am facing similar issue.

I am sending the same endpoints as in the initial Discovery Response, to AddOrUpdateReport but am getting 400 as an error.

Is there a solution yet?

1 comment
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Hello there,

Please share "AddOrUpdateReport" payload with us for further investigation.

Please also share how you are getting access token to call this event api?

0 Likes 0 ·
Mike avatar image
Mike answered

I just hit the same issues as above; error 400 Bad Request, invalid request exception.

Even if this is an old thread, there is no feedback as to how the issue got resolved, so I decided to contribute with a possible solution.

In my case the authorization header was missing. I'm using the same code for Change Reports & Doorbell events. Both are working fine without the authorization header. Even if the documentation indicates the header needs to be included, I did not think this was the problem since the other events (ChangeReport, Doorbell) were working fine.

The GW API should reply with an error 401 if the Auth header is missing. Error 400 is very misleading, you concentrate on the JSON format, not on the headers.

1 comment
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Thanks so much, Mike! I was missing the auth header and was spending all my debugging time looking at the request body instead. I agree that a 401 response would be ideal, though the inconsistency for other events would still be confusing.
0 Likes 0 ·