# Why Cloud connected stateCallback interaction type has BAD-REQUEST error response?

**URL:** <https://community.smartthings.com/t/why-cloud-connected-statecallback-interaction-type-has-bad-request-error-response/232588>\
**Category:** Support\
**Tags:** developers\
**Created:** [October 4, 2021, 7:38am UTC](https://community.smartthings.com/t/why-cloud-connected-statecallback-interaction-type-has-bad-request-error-response/232588 "2021-10-04T07:38:51Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![exosite](https://avatars.discourse-cdn.com/v4/letter/e/ccd318/32.png) [@exosite](https://community.smartthings.com/u/exosite)\
**Post date:** [October 4, 2021, 7:38am UTC](https://community.smartthings.com/t/why-cloud-connected-statecallback-interaction-type-has-bad-request-error-response/232588/1 "2021-10-04T07:38:51Z")

</div>

I am implementing SmartThings Cloud Connected devices to my system.  
I faced a problem while sending Device State Callback:

After OAuth login, finishing Discovery interaction type response and saving the access token to my system, I sent a Device State Callback request to smartThings like this:

```auto
{
    "authentication": {
        "tokenType": "Bearer",
        "token": "###"
    },
    "deviceState": [
        {
            "externalDeviceId": "20F543E0ED3BD5CC5661D4F1_LIGHT",
            "states": [
                {
                    "attribute": "level",
                    "value": 25,
                    "capability": "st.switchLevel",
                    "timestamp": 1633318280000,
                    "component": "main"
                },
                {
                    "attribute": "switch",
                    "value": "on",
                    "capability": "st.switch",
                    "timestamp": 1633318280000,
                    "component": "main"
                },
                {
                    "attribute": "healthStatus",
                    "value": "online",
                    "capability": "st.healthCheck",
                    "timestamp": 1633318280000,
                    "component": "main"
                }
            ]
        },
        {
            "externalDeviceId": "20F543E0ED3BD5CC5661D4F1_FAN",
            "states": [
                {
                    "attribute": "fanSpeed",
                    "value": 0,
                    "capability": "st.fanSpeed",
                    "timestamp": 1633318281000,
                    "component": "main"
                },
                {
                    "attribute": "switch",
                    "value": "on",
                    "capability": "st.switch",
                    "timestamp": 1633318281000,
                    "component": "main"
                },
                {
                    "attribute": "healthStatus",
                    "value": "online",
                    "capability": "st.healthCheck",
                    "timestamp": 1633318281000,
                    "component": "main"
                }
            ]
        }
    ],
    "headers": {
        "requestId": "FAF8BE73D71D925CE3E",
        "interactionType": "stateCallback",
        "schema": "st-schema",
        "version": "1.0"
    }
}

```

I can receive normal response 204 and the device state in SmartThings APP was synchronized in the beginning but after a period of time I received 400 error status code and the response body is like this:

```auto
{
    "headers": {
        "schema": "st-schema",
        "version": "1.0",
        "interactionType": "stateCallback",
        "requestId": "FAF8BE73D71D925CE3E"
    },
    "deviceState": [
        {
            "externalDeviceId": "20F543E0ED3BD5CC5661D4F1_LIGHT",
            "deviceError": [
                {
                    "errorEnum": "BAD-REQUEST",
                    "detail": "deviceState[0] does not correspond to any ST device"
                }
            ]
        },
        {
            "externalDeviceId": "20F543E0ED3BD5CC5661D4F1_FAN",
            "deviceError": [
                {
                    "errorEnum": "BAD-REQUEST",
                    "detail": "deviceState[1] does not correspond to any ST device"
                }
            ]
        }
    ]
}

```

According to the deviceError, I don’t know why deviceState[0] (st.switchLevel) is illegal for a “c2c-dimmer” device handler and why deviceState1 is illegal for a “c2c-fan-controller-4speed” device handler?  
I think my Device State Callback request is legal, please tell me where I was wrong?

My Discovery Response to SmartThings is this:

```auto
{
    "requestGrantCallbackAccess": true,
    "devices": [
        {
            "externalDeviceId": "20F543E0ED3BD5CC5661D4F1_LIGHT",
            "deviceHandlerType": "c2c-dimmer",
            "manufacturerInfo": {
                "hwVersion": "4.0.0",
                "modelName": "type1-1",
                "swVersion": "2.2.0",
                "manufacturerName": "TENX"
            },
            "friendlyName": "My New My Product Light 20F543E0ED3BD5CC5661D4F1"
        },
        {
            "externalDeviceId": "20F543E0ED3BD5CC5661D4F1_FAN",
            "deviceHandlerType": "c2c-fan-controller-4speed",
            "manufacturerInfo": {
                "hwVersion": "4.0.0",
                "modelName": "type1-1",
                "swVersion": "2.2.0",
                "manufacturerName": "TENX"
            },
            "friendlyName": "My Product Fan 20F543E0ED3BD5CC5661D4F1"
        }
    ],
    "headers": {
        "requestId": "50C703D7-8C5E-4669-8CBB-7877E6CD5C71",
        "interactionType": "discoveryResponse",

        "schema": "st-schema",
        "version": "1.0"
    }
}

```

---

<div class="post-metadata">

**Author:** ![erickv](https://yyz2.discourse-cdn.com/smartthings/user_avatar/community.smartthings.com/erickv/32/230792_2.png) [@erickv](https://community.smartthings.com/u/erickv)\
**Post date:** [October 4, 2021, 1:18pm UTC](https://community.smartthings.com/t/why-cloud-connected-statecallback-interaction-type-has-bad-request-error-response/232588/2 "2021-10-04T13:18:09Z")

</div>

Hey, @exosite

I’m quite sure that it is because you’re trying to push a _Health Check (healthStatus)_ state, but such capability is not supported by any [Device Handler Type](https://developer-preview.smartthings.com/docs/devices/cloud-connected/device-handler-types).

Please remove it and let me know if it helps.

---

<div class="post-metadata">

**Author:** ![exosite](https://avatars.discourse-cdn.com/v4/letter/e/ccd318/32.png) [@exosite](https://community.smartthings.com/u/exosite)\
**Post date:** [October 5, 2021, 3:33am UTC](https://community.smartthings.com/t/why-cloud-connected-statecallback-interaction-type-has-bad-request-error-response/232588/3 "2021-10-05T03:33:53Z")

</div>

Hi, Eric

But the [Device State Callback example](https://developer-preview.smartthings.com/docs/devices/cloud-connected/interaction-types#device-state-callback) in document has health check. And [in the beginning of device handler page](https://developer-preview.smartthings.com/docs/devices/cloud-connected/device-handler-types) says the Health Check and Refresh Capabilities are mandatory for each Device Profile. The health check is legal in [State Refresh Response](https://developer-preview.smartthings.com/docs/devices/cloud-connected/interaction-types#state-refresh) and [Command Response](https://developer-preview.smartthings.com/docs/devices/cloud-connected/interaction-types#command) but illegal in [Device State Callback](https://developer-preview.smartthings.com/docs/devices/cloud-connected/interaction-types#device-state-callback)? I am very confused. Please clarify that I should follow your suggestion or the document? I will try your suggestion by the way.

---

<div class="post-metadata">

**Author:** ![erickv](https://yyz2.discourse-cdn.com/smartthings/user_avatar/community.smartthings.com/erickv/32/230792_2.png) [@erickv](https://community.smartthings.com/u/erickv)\
**Post date:** [October 5, 2021, 12:46pm UTC](https://community.smartthings.com/t/why-cloud-connected-statecallback-interaction-type-has-bad-request-error-response/232588/5 "2021-10-05T12:46:42Z")

</div>

It’s really interesting some of the inconsistencies you’ve found right there.

> [@exosite](#):
>
> But the [Device State Callback example](https://developer-preview.smartthings.com/docs/devices/cloud-connected/interaction-types#device-state-callback) in document has health check

You’re right, it shouldn’t have it, since the `c2c-rgbw-color-bulb`, doesn’t support Health Check.

* * *

> [@exosite](#):
>
> Health Check and Refresh Capabilities are mandatory for each Device Profile

This is true for _device profiles_, which is the case of the second device example _(`pdevice-2`)_ which provides usage reference of a custom _device profile_.

* * *

> [@exosite](#):
>
> I am very confused. Please clarify that I should follow your suggestion or the document?

I’ll suggest some changes to that document to improve the context provided. Also, to have a better level of consistency across your integration, I recommend you build your custom _device profile_ at the [Developer Workspace](https://smartthings.developer.samsung.com/workspace/deviceprofiles).

---

<div class="post-metadata">

**Author:** ![exosite](https://avatars.discourse-cdn.com/v4/letter/e/ccd318/32.png) [@exosite](https://community.smartthings.com/u/exosite)\
**Post date:** [October 7, 2021, 2:30am UTC](https://community.smartthings.com/t/why-cloud-connected-statecallback-interaction-type-has-bad-request-error-response/232588/6 "2021-10-07T02:30:34Z")

</div>

Hi Eric,

I tried your suggestion but still got the same error. I have removed the Health Check state. During my working daytime, I won’t see this error. After a night, when I came back to the office in the morning. I push the device button to change the status then my log shows this error again.

```auto
{
    "authentication": {
        "tokenType": "Bearer",
        "token": "###"
    },
    "deviceState": [
        {
            "externalDeviceId": "20F543E0ED3BD5CC5661D4F1_LIGHT",
            "states": [
                {
                    "attribute": "level",
                    "value": 25,
                    "capability": "st.switchLevel",
                    "timestamp": 1633572680000,
                    "component": "main"
                },
                {
                    "attribute": "switch",
                    "value": "on",
                    "capability": "st.switch",
                    "timestamp": 1633572680000,
                    "component": "main"
                }
            ]
        },
        {
            "externalDeviceId": "20F543E0ED3BD5CC5661D4F1_FAN",
            "states": [
                {
                    "attribute": "fanSpeed",
                    "value": 1,
                    "capability": "st.fanSpeed",
                    "timestamp": 1633572680000,
                    "component": "main"
                },
                {
                    "attribute": "switch",
                    "value": "on",
                    "capability": "st.switch",
                    "timestamp": 1633572680000,
                    "component": "main"
                }
            ]
        }
    ],
    "headers": {
        "requestId": "FA1F6B1FBB76FE02B79",
        "interactionType": "stateCallback",
        "schema": "st-schema",
        "version": "1.0"
    }
}

```

The response:

```auto
{
    "body": "{\"headers\":{\"schema\":\"st-schema\",\"version\":\"1.0\",\"interactionType\":\"stateCallback\",\"requestId\":\"FA1F6B1FBB76FE02B79\"},\"deviceState\":[{\"externalDeviceId\":\"20F543E0ED3BD5CC5661D4F1_LIGHT\",\"deviceError\":[{\"errorEnum\":\"BAD-REQUEST\",\"detail\":\"deviceState[0] does not correspond to any ST device\"}]},{\"externalDeviceId\":\"20F543E0ED3BD5CC5661D4F1_FAN\",\"deviceError\":[{\"errorEnum\":\"BAD-REQUEST\",\"detail\":\"deviceState[1] does not correspond to any ST device\"}]}]}",
    "status_code": 400,
    "headers": {
        "x-amz-apigw-id": "G0KTWEiYoAMF3zw=",
        "X-Amz-Cf-Pop": "SFO5-C1",
        "X-Cache": "Error from cloudfront",
        "Date": "Thu, 07 Oct 2021 02:11:20 GMT",
        "Content-Type": "application/json",
        "Content-Length": "454",
        "X-Amzn-Trace-Id": "Root=1-615e5748-5437539f250b95e93c1f5ee4;Sampled=0",
        "Connection": "keep-alive",
        "x-amzn-RequestId": "1816cb8a-8958-4bfd-888e-d09b124c9167",
        "Via": "1.1 36a6d536e73f7d347cd93b9a754ee828.cloudfront.net (CloudFront)",
        "X-Amz-Cf-Id": "vXXNZAff15RCOIaMc-mCmUCbSmhSnsRrF1AtuLye9btpUMKVdEKphA=="
    }
}

```

The response body:

```auto
{
    "headers": {
        "schema": "st-schema",
        "version": "1.0",
        "interactionType": "stateCallback",
        "requestId": "FA1F6B1FBB76FE02B79"
    },
    "deviceState": [
        {
            "externalDeviceId": "20F543E0ED3BD5CC5661D4F1_LIGHT",
            "deviceError": [
                {
                    "errorEnum": "BAD-REQUEST",
                    "detail": "deviceState[0] does not correspond to any ST device"
                }
            ]
        },
        {
            "externalDeviceId": "20F543E0ED3BD5CC5661D4F1_FAN",
            "deviceError": [
                {
                    "errorEnum": "BAD-REQUEST",
                    "detail": "deviceState[1] does not correspond to any ST device"
                }
            ]
        }
    ]
}

```

---

<div class="post-metadata">

**Author:** ![erickv](https://yyz2.discourse-cdn.com/smartthings/user_avatar/community.smartthings.com/erickv/32/230792_2.png) [@erickv](https://community.smartthings.com/u/erickv)\
**Post date:** [October 7, 2021, 2:41am UTC](https://community.smartthings.com/t/why-cloud-connected-statecallback-interaction-type-has-bad-request-error-response/232588/7 "2021-10-07T02:41:44Z")

</div>

Hmmm, this is interesting. Let me share this with our team and double-check if we’re not hitting an unexpected bug.

---

<div class="post-metadata">

**Author:** ![exosite](https://avatars.discourse-cdn.com/v4/letter/e/ccd318/32.png) [@exosite](https://community.smartthings.com/u/exosite)\
**Post date:** [October 7, 2021, 4:34am UTC](https://community.smartthings.com/t/why-cloud-connected-statecallback-interaction-type-has-bad-request-error-response/232588/8 "2021-10-07T04:34:43Z")

</div>

I am pretty sure my Reciprocal Access Token is not expired and even I refreshed it, the error is still the same.

```auto
{
    "message": "SmartThingsModel.refreshCallbackAccessToken response",
    "refreshCallbackAccessTokenResponse": {
        "body": "{\"headers\":{\"schema\":\"st-schema\",\"version\":\"1.0\",\"interactionType\":\"accessTokenResponse\",\"requestId\":\"61DA1E9C216F2796951\"},\"callbackAuthentication\":{\"tokenType\":\"Bearer\",\"accessToken\":\"###\",\"refreshToken\":\"###\",\"expiresIn\":86400}}",
        "status_code": 200,
        "headers": {
            "x-amz-apigw-id": "G0QbCGogIAMFi4A=",
            "X-Amz-Cf-Pop": "SFO20-C1",
            "X-Cache": "Miss from cloudfront",
            "Date": "Thu, 07 Oct 2021 02:53:07 GMT",
            "Content-Type": "application/json",
            "Content-Length": "569",
            "X-Amzn-Trace-Id": "Root=1-615e6113-3910ce4846e1ce98292707f5;Sampled=1",
            "Connection": "keep-alive",
            "x-amzn-RequestId": "87171a27-7210-4c02-838d-3b97d38505d5",
            "Via": "1.1 67c5370c4ea2e5f9f865960e31ef2d86.cloudfront.net (CloudFront)",
            "X-Amz-Cf-Id": "gz2ZB5BrLdTYe9ZTyxf_Oh3UyEel7IhLgUkAChb5rDLKg10ZwWbfgA=="
        }
    },
    "module": "smartthings_model"
}

```

There’s another finding.  
Under current error situation if I send [Discovery Callback request](https://developer-preview.smartthings.com/docs/devices/cloud-connected/interaction-types#discovery-callback), The response was 204 seems successful but the new device did not show in SmartThings APP.

My Discovery Callback Request:

```auto
{
    "authentication": {
        "tokenType": "Bearer",
        "token": "###"
    },
    "devices": [
        {
            "externalDeviceId": "88835D98B2BF366A5E61B058_LIGHT",
            "deviceHandlerType": "c2c-dimmer",
            "manufacturerInfo": {
                "hwVersion": "4.0.0",
                "modelName": "type1-1",
                "swVersion": "2.4.0",
                "manufacturerName": "TENX"
            },
            "friendlyName": "88835D98B2BF Light 88835D98B2BF366A5E61B058"
        },
        {
            "externalDeviceId": "88835D98B2BF366A5E61B058_FAN",
            "deviceHandlerType": "c2c-fan-controller-4speed",
            "manufacturerInfo": {
                "hwVersion": "4.0.0",
                "modelName": "type1-1",
                "swVersion": "2.4.0",
                "manufacturerName": "TENX"
            },
            "friendlyName": "88835D98B2BF Fan 88835D98B2BF366A5E61B058"
        }
    ],
    "headers": {
        "requestId": "913C15B331F5182A810",
        "interactionType": "discoveryCallback",
        "schema": "st-schema",
        "version": "1.0"
    }
}

```

Received Discovery Callback Respoonse:

```auto
{
    "discoveryCallbackResponse": {
        "body": "",
        "status_code": 204,
        "headers": {
            "x-amz-apigw-id": "G0XS8GA0IAMFu-w=",
            "X-Amz-Cf-Pop": "SFO5-C1",
            "X-Cache": "Miss from cloudfront",
            "Date": "Thu, 07 Oct 2021 03:40:03 GMT",
            "Content-Type": "application/json",
            "Content-Length": "0",
            "X-Amzn-Trace-Id": "Root=1-615e6c12-4c639c632f0607521f598de3;Sampled=1",
            "Connection": "keep-alive",
            "x-amzn-RequestId": "fd54b74b-7ad0-4cee-b299-998618a82e4d",
            "Via": "1.1 be84d08eeed51234cd122d3c30e6f7c1.cloudfront.net (CloudFront)",
            "X-Amz-Cf-Id": "A-RVlqPRO_fbNeXs7xceRWhL83V4qKq2AQ3eOJVPorGTYxXJ5v3R-g=="
        }
    },
    "module": "smartthings_model",
    "message": "SmartThingsModel.sendDiscoveryCallback response"
}

```

But send [list devices API](https://developer-preview.smartthings.com/api/public/#operation/getDevices) to list my devices, I cannot see my device “88835D98B2BF Light 88835D98B2BF366A5E61B058” added successfully.

```auto
[
    {
        "restrictionTier": 0,
        "roomId": "7b3a428b-1ce0-4e2a-9781-800fc71d1912",
        "name": "c2c-dimmer",
        "viper": {
            "hwVersion": "4.0.0",
            "modelName": "type1-1",
            "swVersion": "2.4.0",
            "manufacturerName": "TENX"
        },
        "profile": {
            "id": "3a743caf-1268-424f-8d7a-c0a280a82910"
        },
        "createTime": "2021-10-06T11:03:55.802Z",
        "deviceId": "51dc0809-57e2-4854-a023-2e801f30022a",
        "label": "device1 Light 88835D98B2A2AB785D61C101",
        "manufacturerName": "SmartThings",
        "type": "VIPER",
        "presentationId": "SmartThings-smartthings-c2c-dimmer",
        "components": [
            {
                "categories": [
                    {
                        "name": "Light",
                        "categoryType": "manufacturer"
                    }
                ],
                "capabilities": [
                    {
                        "version": 1,
                        "id": "switch"
                    },
                    {
                        "version": 1,
                        "id": "switchLevel"
                    },
                    {
                        "version": 1,
                        "id": "refresh"
                    },
                    {
                        "version": 1,
                        "id": "healthCheck"
                    }
                ],
                "id": "main"
            }
        ],
        "locationId": "f64d1996-db82-4ee0-92cc-06a9c4a75371"
    },
    {
        "restrictionTier": 0,
        "roomId": "7b3a428b-1ce0-4e2a-9781-800fc71d1912",
        "name": "c2c-fan-controller-4speed",
        "viper": {
            "hwVersion": "4.0.0",
            "modelName": "type1-1",
            "swVersion": "2.2.0",
            "manufacturerName": "TENX"
        },
        "profile": {
            "id": "d77d72d7-5912-4e4b-a474-b093ce42fbac"
        },
        "createTime": "2021-10-06T05:51:48.619Z",
        "deviceId": "489ddc99-7623-41c0-9d8c-7c121dfc8bba",
        "label": "My device1 Fan 20F543E0ED3BD5CC5661D4F1",
        "manufacturerName": "SmartThings",
        "type": "VIPER",
        "presentationId": "SmartThings-smartthings-c2c-fan-controller-4speed",
        "components": [
            {
                "categories": [
                    {
                        "name": "Fan",
                        "categoryType": "manufacturer"
                    }
                ],
                "capabilities": [
                    {
                        "version": 1,
                        "id": "healthCheck"
                    },
                    {
                        "version": 1,
                        "id": "refresh"
                    },
                    {
                        "version": 1,
                        "id": "switch"
                    },
                    {
                        "version": 1,
                        "id": "fanSpeed"
                    }
                ],
                "id": "main"
            }
        ],
        "locationId": "f64d1996-db82-4ee0-92cc-06a9c4a75371"
    },
    {
        "restrictionTier": 0,
        "roomId": "7b3a428b-1ce0-4e2a-9781-800fc71d1912",
        "name": "c2c-dimmer",
        "viper": {
            "hwVersion": "4.0.0",
            "modelName": "type1-1",
            "swVersion": "2.2.0",
            "manufacturerName": "TENX"
        },
        "profile": {
            "id": "3a743caf-1268-424f-8d7a-c0a280a82910"
        },
        "createTime": "2021-10-06T05:51:48.618Z",
        "deviceId": "0b0cd219-caa0-4375-ac52-6f22acf1990d",
        "label": "My device1 Light 20F543E0ED3BD5CC5661D4F1",
        "manufacturerName": "SmartThings",
        "type": "VIPER",
        "presentationId": "SmartThings-smartthings-c2c-dimmer",
        "components": [
            {
                "categories": [
                    {
                        "name": "Light",
                        "categoryType": "manufacturer"
                    }
                ],
                "capabilities": [
                    {
                        "version": 1,
                        "id": "switch"
                    },
                    {
                        "version": 1,
                        "id": "switchLevel"
                    },
                    {
                        "version": 1,
                        "id": "refresh"
                    },
                    {
                        "version": 1,
                        "id": "healthCheck"
                    }
                ],
                "id": "main"
            }
        ],
        "locationId": "f64d1996-db82-4ee0-92cc-06a9c4a75371"
    },
    {
        "restrictionTier": 0,
        "roomId": "7b3a428b-1ce0-4e2a-9781-800fc71d1912",
        "name": "c2c-fan-controller-4speed",
        "viper": {
            "hwVersion": "4.0.0",
            "modelName": "type1-1",
            "swVersion": "2.4.0",
            "manufacturerName": "TENX"
        },
        "profile": {
            "id": "d77d72d7-5912-4e4b-a474-b093ce42fbac"
        },
        "createTime": "2021-10-06T11:03:55.803Z",
        "deviceId": "b65e4bba-54c6-4310-93b6-974c499e97b6",
        "label": "device1 Fan 88835D98B2A2AB785D61C101",
        "manufacturerName": "SmartThings",
        "type": "VIPER",
        "presentationId": "SmartThings-smartthings-c2c-fan-controller-4speed",
        "components": [
            {
                "categories": [
                    {
                        "name": "Fan",
                        "categoryType": "manufacturer"
                    }
                ],
                "capabilities": [
                    {
                        "version": 1,
                        "id": "healthCheck"
                    },
                    {
                        "version": 1,
                        "id": "refresh"
                    },
                    {
                        "version": 1,
                        "id": "switch"
                    },
                    {
                        "version": 1,
                        "id": "fanSpeed"
                    }
                ],
                "id": "main"
            }
        ],
        "locationId": "f64d1996-db82-4ee0-92cc-06a9c4a75371"
    }
]

```

 ![截圖 2021-10-07 下午12.19.44](https://global.discourse-cdn.com/smartthings/original/3X/2/b/2b8c41ccc515cc12d0667c76e2315fe16027da37.png)

In conclusion:

1. After a period of time(for me, after leaving office from 7:00pm to the next day 9:30AM ) the error showed up. It’s hard to test how long it will happen.
2. I have checked the the access token was not expired.
3. Under the error situation, even I refreshed access token, I still got the same error.
4. Under the error situation, the Discovery Callback returned 204 which seems successful, but my new device wouldn’t show in SmartThings APP. And I checked with list devices API. It is truly not added in my device list.

The error can be gone if I do adding devices in SmartThings APP ( [Discovery](https://developer-preview.smartthings.com/docs/devices/cloud-connected/interaction-types) ) again. But users won’t know that. They will feel weird why need to do adding devices again. Please notice that the error will happen again after a nighttime.

 ![截圖 2021-10-07 下午12.26.37](https://global.discourse-cdn.com/smartthings/original/3X/9/2/92bd7c8221fc11dc783c36bc5697dba00e64c4b7.png)

---

<div class="post-metadata">

**Author:** ![erickv](https://yyz2.discourse-cdn.com/smartthings/user_avatar/community.smartthings.com/erickv/32/230792_2.png) [@erickv](https://community.smartthings.com/u/erickv)\
**Post date:** [October 7, 2021, 2:25pm UTC](https://community.smartthings.com/t/why-cloud-connected-statecallback-interaction-type-has-bad-request-error-response/232588/9 "2021-10-07T14:25:41Z")

</div>

> [@exosite](#):
>
> But users won’t know that. They will feel weird why need to do adding devices again.

I agree, and that’s the purpose of the callbacks, to provide consistency across platforms.

So, I’ve been checking if other partners were experiencing these or similar issues, and yes, some of them reported unexpected errors from callbacks, `stateCallback` precisely.

In addition, I’ve documented your issue specifically, and as soon as I have a resolution from our engineers, I’ll share with you the details.

---

<div class="post-metadata">

**Author:** ![erickv](https://yyz2.discourse-cdn.com/smartthings/user_avatar/community.smartthings.com/erickv/32/230792_2.png) [@erickv](https://community.smartthings.com/u/erickv)\
**Post date:** [October 19, 2021, 3:26pm UTC](https://community.smartthings.com/t/why-cloud-connected-statecallback-interaction-type-has-bad-request-error-response/232588/10 "2021-10-19T15:26:20Z")

</div>

Hey, @exosite

Following up on this issue, our team has reviewed the backend logs according to the request Ids referred above, and they’ve mentioned that the callbacks were failing because the _externalDeviceId_ wasn’t consistent with the actual Ids of the devices recently created.

Also, could you confirm if you’re still having issues while sending _State Callbacks_.

---

<div class="post-metadata">

**Author:** ![Britzy](https://yyz2.discourse-cdn.com/smartthings/user_avatar/community.smartthings.com/britzy/32/146106_2.png) [@Britzy](https://community.smartthings.com/u/Britzy)\
**Post date:** [October 20, 2021, 2:01am UTC](https://community.smartthings.com/t/why-cloud-connected-statecallback-interaction-type-has-bad-request-error-response/232588/11 "2021-10-20T02:01:03Z")

</div>

After Oct 13, my Cloud Connect Project got same problem. (even published and use in business)

callback and even discovery, command…

BAD-RESPONSE (Invalid schema specified)

but I don’t change anything 3 months.

interactionResult have no originatingInteractionType (just “”).

```auto
{
    "headers": {
        "schema": "st-schema",
        "interactionType": "interactionResult",
        "requestId": "F1BB1EA0-A977-4957-8474-1372A3101121",
        "version": "1.0"
    },
    "globalError": {
        "errorEnum": "BAD-RESPONSE",
        "detail": "Invalid schema specified"
    },
    "originatingInteractionType": "",
    "authentication": {
        "tokenType": "Bearer",
        "token": "3RD TOKEN"
    }
}

```

My topics are hidden by spam detect bot(I don’t know why they do)

---

<div class="post-metadata">

**Author:** ![Britzy](https://yyz2.discourse-cdn.com/smartthings/user_avatar/community.smartthings.com/britzy/32/146106_2.png) [@Britzy](https://community.smartthings.com/u/Britzy)\
**Post date:** [October 20, 2021, 6:43am UTC](https://community.smartthings.com/t/why-cloud-connected-statecallback-interaction-type-has-bad-request-error-response/232588/12 "2021-10-20T06:43:35Z")

</div>

It’s work properly at this time.

---

<div class="post-metadata">

**Author:** ![exosite](https://avatars.discourse-cdn.com/v4/letter/e/ccd318/32.png) [@exosite](https://community.smartthings.com/u/exosite)\
**Post date:** [October 20, 2021, 7:44am UTC](https://community.smartthings.com/t/why-cloud-connected-statecallback-interaction-type-has-bad-request-error-response/232588/13 "2021-10-20T07:44:08Z")

</div>

Hi, Erik.

I added some devices in SmartThings APP and will leave them after duty for a night. I will observe if the errors still come out next day.

```auto
{
    "payload": {
        "response": {
            "code": 200,
            "request_id": "MjAuMjk=-b1ziusij85etc0000-29f35443",
            "message": {
                "requestGrantCallbackAccess": true,
                "devices": [
                    {
                        "externalDeviceId": "88835D98B2BF2C396E61DC58_LIGHT",
                        "deviceHandlerType": "c2c-dimmer",
                        "manufacturerInfo": {
                            "hwVersion": "4.0.0",
                            "modelName": "type1-1",
                            "swVersion": "2.4.0",
                            "manufacturerName": "TENX"
                        },
                        "friendlyName": "D3 Light 88835D98B2BF2C396E61DC58"
                    },
                    {
                        "externalDeviceId": "88835D98B2BF2C396E61DC58_FAN",
                        "deviceHandlerType": "c2c-fan-controller-4speed",
                        "manufacturerInfo": {
                            "hwVersion": "4.0.0",
                            "modelName": "type1-1",
                            "swVersion": "2.4.0",
                            "manufacturerName": "TENX"
                        },
                        "friendlyName": "D3 Fan 88835D98B2BF2C396E61DC58"
                    },
                    {
                        "externalDeviceId": "20F543E0ED3B465C6E61EAF1_LIGHT",
                        "deviceHandlerType": "c2c-dimmer",
                        "manufacturerInfo": {
                            "hwVersion": "4.0.0",
                            "modelName": "type1-1",
                            "swVersion": "2.2.0",
                            "manufacturerName": "TENX"
                        },
                        "friendlyName": "D1 Light 20F543E0ED3B465C6E61EAF1"
                    },
                    {
                        "externalDeviceId": "20F543E0ED3B465C6E61EAF1_FAN",
                        "deviceHandlerType": "c2c-fan-controller-4speed",
                        "manufacturerInfo": {
                            "hwVersion": "4.0.0",
                            "modelName": "type1-1",
                            "swVersion": "2.2.0",
                            "manufacturerName": "TENX"
                        },
                        "friendlyName": "D1 Fan 20F543E0ED3B465C6E61EAF1"
                    },
                    {
                        "externalDeviceId": "88835D98B2A23A4E6E61D101_LIGHT",
                        "deviceHandlerType": "c2c-dimmer",
                        "manufacturerInfo": {
                            "hwVersion": "4.0.0",
                            "modelName": "type1-1",
                            "swVersion": "2.4.0",
                            "manufacturerName": "TENX"
                        },
                        "friendlyName": "D2 Light 88835D98B2A23A4E6E61D101"
                    },
                    {
                        "externalDeviceId": "88835D98B2A23A4E6E61D101_FAN",
                        "deviceHandlerType": "c2c-fan-controller-4speed",
                        "manufacturerInfo": {
                            "hwVersion": "4.0.0",
                            "modelName": "type1-1",
                            "swVersion": "2.4.0",
                            "manufacturerName": "TENX"
                        },
                        "friendlyName": "D2 Fan 88835D98B2A23A4E6E61D101"
                    }
                ],
                "headers": {
                    "requestId": "51D35B35-32DD-4BB5-BDB9-5017E9638298",
                    "interactionType": "discoveryResponse",
                    "schema": "st-schema",
                    "version": "1.0"
                }
            },
            "headers": {
                "content-type": "text/plain"
            }
        }
    },
    "module": "SmartThingsController",
    "message": "SmartThingsController.discovery response"
}

```

---

<div class="post-metadata">

**Author:** ![erickv](https://yyz2.discourse-cdn.com/smartthings/user_avatar/community.smartthings.com/erickv/32/230792_2.png) [@erickv](https://community.smartthings.com/u/erickv)\
**Post date:** [October 20, 2021, 4:03pm UTC](https://community.smartthings.com/t/why-cloud-connected-statecallback-interaction-type-has-bad-request-error-response/232588/14 "2021-10-20T16:03:16Z")

</div>

> [@exosite](#):
>
> I added some devices in SmartThings APP and will leave them after duty for a night. I will observe if the errors still come out next day.

Great! I’ll stay pending on these results.

* * *

@Britzy That’s unfortunate, but I’m glad it is now working as expected. Next time you face this or similar issues with your _Schema Connector_, please do not hesitate in writing to us at [build@smartthings.com](mailto:build@smartthings.com).

---

<div class="post-metadata">

**Author:** ![exosite](https://avatars.discourse-cdn.com/v4/letter/e/ccd318/32.png) [@exosite](https://community.smartthings.com/u/exosite)\
**Post date:** [October 21, 2021, 11:09am UTC](https://community.smartthings.com/t/why-cloud-connected-statecallback-interaction-type-has-bad-request-error-response/232588/15 "2021-10-21T11:09:47Z")

</div>

Hi Erik.

So far the receiving state callback responses are all 204.

```auto
{
    "message": "SmartThingsModel.sendStateCallback response",
    "stateCallbackResponse": {
        "body": "",
        "status_code": 204,
        "headers": {
            "x-amz-apigw-id": "HjeW8HQZoAMFwRg=",
            "X-Amz-Cf-Pop": "SFO5-C3",
            "X-Cache": "Miss from cloudfront",
            "Date": "Thu, 21 Oct 2021 10:42:52 GMT",
            "Content-Type": "application/json",
            "Content-Length": "0",
            "X-Amzn-Trace-Id": "Root=1-6171442c-38ca90f7585a9cfd08467445;Sampled=0",
            "Connection": "keep-alive",
            "x-amzn-RequestId": "14798927-29b5-4935-b094-59df8933dd58",
            "Via": "1.1 6328d32449cd285f3f7c7b3c41dbe9ad.cloudfront.net (CloudFront)",
            "X-Amz-Cf-Id": "6PAZQzU5jHvaWZAAA-i1VTLDRePqmTraIZo8u7DynnQvhvZh8NtY-w=="
        }
    },
    "module": "smartthings_model"
}

```

These days I did some modification. Previously I saved the callback access token in our Redis with key smartthings\_access\_token. However, this caused an issue, Let me explain step by step:

1. In the phone A, the user A logged in our ExoHome APP(our product) and paired our device then in SmartThing APP OAuth logged in the do adding devices and saved the callback access token.
2. In the phone B, the user B logged in our ExoHome APP and paired another device then surprisedly the device will show in user A’s SmartThings APP!!!
3. This issue happened because the user B use the user A’s callback access token to do discovery callback. so the user B’s device will be added in the user A’s SmartThings APP.
4. I changed to save each user’s callback access token in the Redis with key user\_{{user\_id}}\_callback\_access\_token.
5. So far there’s no BAD-REQUEST i mentioned.

---

<div class="post-metadata">

**Author:** ![erickv](https://yyz2.discourse-cdn.com/smartthings/user_avatar/community.smartthings.com/erickv/32/230792_2.png) [@erickv](https://community.smartthings.com/u/erickv)\
**Post date:** [October 21, 2021, 12:23pm UTC](https://community.smartthings.com/t/why-cloud-connected-statecallback-interaction-type-has-bad-request-error-response/232588/16 "2021-10-21T12:23:15Z")

</div>

> [@exosite](#):
>
> 1. In the phone A, the user A logged in our ExoHome APP(our product) and paired our device then in SmartThing APP OAuth logged in the do adding devices and saved the callback access token.
> 2. In the phone B, the user B logged in our ExoHome APP and paired another device then surprisedly the device will show in user A’s SmartThings APP!!!
> 3. This issue happened because the user B use the user A’s callback access token to do discovery callback. so the user B’s device will be added in the user A’s SmartThings APP.

Just for reference, _user A_ and _userB_ are using different _ExoHome_ account, right? Because it seems that _user sessions_ were overlapping on your _Schema Connector_.

* * *

> [@exosite](#):
>
> 1. So far there’s no BAD-REQUEST i mentioned.

So, your _Schema Callbacks_ are now working as expected, right?

---

<div class="post-metadata">

**Author:** ![exosite](https://avatars.discourse-cdn.com/v4/letter/e/ccd318/32.png) [@exosite](https://community.smartthings.com/u/exosite)\
**Post date:** [October 25, 2021, 1:56am UTC](https://community.smartthings.com/t/why-cloud-connected-statecallback-interaction-type-has-bad-request-error-response/232588/17 "2021-10-25T01:56:32Z")

</div>

> [@erickv](#):
>
> Just for reference, _user A_ and _userB_ are using different _ExoHome_ account, right? Because it seems that _user sessions_ were overlapping on your _Schema Connector_ .

Sure, different email.

> [@erickv](#):
>
> So, your _Schema Callbacks_ are now working as expected, right?

Yeah, after 3 days still working well.

```auto
{
    "message": "SmartThingsModel.sendStateCallback response",
    "stateCallbackResponse": {
        "body": "",
        "status_code": 204,
        "headers": {
            "x-amz-apigw-id": "HvbpbH2aIAMFZ8Q=",
            "X-Amz-Cf-Pop": "SFO5-C1",
            "X-Cache": "Miss from cloudfront",
            "Date": "Mon, 25 Oct 2021 01:47:14 GMT",
            "Content-Type": "application/json",
            "Content-Length": "0",
            "X-Amzn-Trace-Id": "Root=1-61760ca2-2986122273108edf00723249;Sampled=0",
            "Connection": "keep-alive",
            "x-amzn-RequestId": "eaff1c24-9da3-409d-987e-44e0cdbb27eb",
            "Via": "1.1 afb9be97319013ab1a18f338fce40f2a.cloudfront.net (CloudFront)",
            "X-Amz-Cf-Id": "YG42w_KzelwAnMlEMNDdA2hV0KEKPC9VPC9NYs-v8v82RZZP7FOkBg=="
        }
    },
    "module": "smartthings_model"
}

```
