-
Notifications
You must be signed in to change notification settings - Fork 493
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug Report] Cannot invoke direct methods with payload in IotEdge devices. #3381
Comments
seems the quotes in the json strings are not properly escaped: string json =
"{\"schemaVersion\": \"1.0\" ... |
I have updated the codes with Github code blocks. |
If the DirectMethodServiceRequest payload is null(the ping direct method), the result will be 200. |
Thanks for reporting this issue, while we investigate can you try with the non-preview version? https://www.nuget.org/packages/Microsoft.Azure.Devices/1.39.0 var serviceClient = ServiceClient.CreateFromConnectionString(connectionString);
string json = """
{
"schemaVersion": "1.0",
"items": [
{
"id": "edgeAgent",
"filter": {
"tail": 3,
"since": "10m",
}
}
],
"encoding": "none",
"contentType": "text"
}
""";
CloudToDeviceMethod request = new("GetModuleLogs");
request.SetPayloadJson(json);
var result = await serviceClient.InvokeDeviceMethodAsync("deviceId", "$edgeAgent", request);
Console.WriteLine(result.Status);
Console.WriteLine(result.GetPayloadAsJson()); |
Hi @rido-min I have made some more tests with server - client sdk with different versions:
Seems there are breaking changes in server direct method payload encoder in preview version sdk makes the client must have preview version to work. |
Yes, this seems like a bug in v2 previews. May I ask what's your motivation to use v2-previews instead of v1 releases? |
@rido-min |
Context
Description of the issue
Cannot invoke direct methods with payload in IotEdge devices.
Code sample exhibiting the issue
Console log of the issue
{"message":"Error parsing command payload because of error - Error converting value "eyJzY2hlbWFWZXJzaW9uIjogIjEuMCIsIml0ZW1zIjogW3siaWQiOiAiaW90ZWRnZWdhdGV3YXkiLCJmaWx0ZXIiOiB7InRhaWwiOiAzLCJzaW5jZSI6ICIxMG0ifX1dLCJlbmNvZGluZyI6ICJub25lIiwiY29udGVudFR5cGUiOiAidGV4dCJ9" to type 'Microsoft.Azure.Devices.Edge.Agent.Core.Requests.ModuleLogsRequest'. Path '', line 1, position 186."}
The text was updated successfully, but these errors were encountered: