aws / aws-iot-device-sdk-cpp

SDK for connecting to AWS IoT from a device using C++
http://aws-iot-device-sdk-cpp-docs.s3-website-us-east-1.amazonaws.com
Apache License 2.0
123 stars 111 forks source link

Shadow Update rejected: code 400 (Missing required node: state) #110

Closed certabitmh closed 6 years ago

certabitmh commented 6 years ago

Hello, I've integrated release 1.4.0 in my project, but I'm not able to update shadow documents. For debugging, I reduced the content of the doc to minimum:

            shadowDeviceDoc = _pShadow->GetEmptyShadowDocument();
            std::unique_lock<std::mutex> block_handler_lock(_sync_action_response_lock);
            {
                _pShadow->UpdateDeviceShadow(shadowDeviceDoc);

                _pShadow->PerformUpdateAsync();

                _sync_action_response_wait.wait_for(block_handler_lock, shadow_action_timeout);

                ResponseCode rc = _sync_action_response;
                if (ResponseCode::SHADOW_REQUEST_REJECTED == rc) {

                    qDebug() << __FUNCTION__ << "Sync Action Failed";
                }
            }

AWS Console shows this error: Shadow Update rejected { "code": 400, "message": "Missing required node: state", "clientToken": "empty" } Console output of doc content using rapidjson writer shows this -> doc DOES include "state":

{\"state\":{\"desired\":{},\"reported\":{}},\"version\":0,\"clientToken\":\"empty\",\"timestamp\":0}"

Any ideas what I'm missing? Maybe there is an issue with encoding?

vareddy-zz commented 6 years ago

Hi @certabitmh, Could you try subscribing to the shadow update topic in the IoT console and checking what document is being sent to cloud (also post that here)? That will help confirm if the correct document is being received by the cloud. Thanks! Varun

JonathanHenson commented 6 years ago

closing pending more info from OP.