aliyun / aliyun-openapi-net-sdk

Alibaba Cloud SDK for .NET
https://www.nuget.org/profiles/aliyun-openapi-sdk
Other
541 stars 625 forks source link

iot在设置设备属性的时候,报iot.check.InvalidFormattedParameter这个错误,阿里云上没有找到对应的错误码 #234

Closed lhg0302 closed 5 years ago

lhg0302 commented 5 years ago

List<dynamic> items = new List<dynamic>(); SetDevicePropertyRequest rRpcRequest = new SetDevicePropertyRequest(); dynamic obj = new ExpandoObject(); obj.key = "Data"; obj.value = "ceshizhong"; items.Add(obj); obj.key = "Status"; obj.value = "1"; items.Add(obj); rRpcRequest.ProductKey = "a1Lersh4ycy"; rRpcRequest.DeviceName = "facedoor1"; rRpcRequest.Items = JsonConvert.SerializeObject(items); SetDevicePropertyResponse rRpcResponse = client.GetAcsResponse(rRpcRequest); 反馈回来报code是iot.check.InvalidFormattedParameter,errormessage是The args parameter format is invalid,我估计是我的items设置有问题,但不知道如何写才正确,麻烦指导一下,谢谢

doublnt commented 5 years ago

好的,稍等。我本地模拟一下,会尽快给您反馈。

doublnt commented 5 years ago

@lhg0302 您好,请问您使用的 iot 和 aliyun.net.sdk.core 的nuget 包是最新版本吗?

doublnt commented 5 years ago

@lhg0302 您好,您可以查看 SetDevicePropertyRequest 的文档https://help.aliyun.com/document_detail/69579.html?spm=a2c4g.11186623.2.44.289631123E9x78#reference-m2h-4rz-wdb

应该是 格式的问题,我在本地测试使用 JsonConvert 转换后的就会报和你出现的一样的错误

item:  [{"key":"LightAdjustLevel","value":1}]
{"ErrorMessage":"The args parameter format is invalid.","","Success":false,"Code":"iot.check.InvalidFormattedParameter"}

格式直接为 key:value 即可,比如"{LightAdjustLevel:1}" 麻烦您测试拼接一下 json 调用