actions-on-google / actions-on-google-nodejs

Node.js client library for Actions on Google
https://actions-on-google.github.io/actions-on-google-nodejs
Apache License 2.0
900 stars 197 forks source link

code = InvalidArgument desc = Request contains an invalid argument. #343

Closed fbens closed 4 years ago

fbens commented 4 years ago

Error Code When I call the ReportStateAndNotification rpc function, it return this error all the time.

error: rpc error: code = InvalidArgument 
desc = Request contains an invalid argument.

Data Send test1

{
    "request_id": "ff36a3cc-ec34-1e6-b1a0-64510650abcf",
    "agent_user_id": "2476592",
    "payload": {
        "devices": {
            "states": {
                "2251959347": {
                    "on": true
                }
            }
        }
    }
}

test2

{
    "requestId": "ff36a3cc-ec34-11e6-b1a0-6451065abcf",
    "agentUserId": "2476592",
    "payload": {
        "devices": {
            "states": {
                "2251959347": {
                    "on": true
                }
            }
        }
    }
}

This error show all the time no matter data I sended with name agent_user_id or agentUserId like above. but I was writted according to the official example ReportStateAndNotificationRequest the parameters send example like below. I am so confused what parameters should I sended

屏幕快照 2019-07-21 13 14 57

Fleker commented 4 years ago

Is the agentUserId a valid id? Does the device have the OnOff trait?

fbens commented 4 years ago

@Fleker It's an valid agentUserId and the device has action.devices.traits.OnOff traits below is the response when calling the Sync function:

{
    "agent_user_id": "2476592",
    "device": {
        "id": "2251959347",
        "type": "action.devices.types.CAMERA",
        "traits": [
            "action.devices.traits.OnOff",
            "action.devices.traits.CameraStream"
        ],
        "name": {
            "name": "DEV02"
        },
        "will_report_state": true,
        "device_info": {},
        "attributes": "\n\n\u0010availableToggles\u0012k2i\ng*e\n\u0010\n\u0004name\u0012\u0008\u001a\u0006record\nQ\n\u000bname_values\u0012B2@\n\u003e*\u003c\n\u000c\n\u0004lang\u0012\u0004\u001a\u0002en\n,\n\u000cname_synonym\u0012\u001c2\u001a\n\u0008\u001a\u0006record\n\u000e\u001a\u000crecord video\n\u001f\n\u0019cameraStreamNeedAuthToken\u0012\u0002 \u0000\n#\n\u001dcameraStreamNeedDrmEncryption\u0012\u0002 \u0000\n+\n\u001ecameraStreamSupportedProtocols\u0012\t2\u0007\n\u0005\u001a\u0003hls",
        "custom_data": "{\"real_type\":null,\"system\":\"ImCoud\"}"
    }
}
Fleker commented 4 years ago

Did you resolve the issue? Is that why you closed it?

fbens commented 4 years ago

@Fleker Yes, problem resolved, thank you very much. :-)