Skip to content

[Bug Report] Cannot invoke direct methods with payload in IotEdge devices. #3381

Open
@Dolphinsimon

Description

@Dolphinsimon

Context

  • **OS, version, SKU and CPU architecture used:Windows 10 Desktop x64
  • **Application's .NET Target Framework : .NET8.0-RC2
  • **Device: Laptop
  • **SDK version used: 2.0.0-preview007
  • IoT Edge version: 1.4.23

Description of the issue

Cannot invoke direct methods with payload in IotEdge devices.

Code sample exhibiting the issue

var serviceClient = new IotHubServiceClient("HostName=***");
string json =
    "{\"schemaVersion\": \"1.0\",\"items\": [{\"id\": \"module\",\"filter\": {\"tail\": 3,\"since\": \"10m\"}}],\"encoding\": \"none\",\"contentType\": \"text\"}";
DirectMethodServiceRequest request = new("GetModuleLogs")
{
    Payload = Encoding.UTF8.GetBytes(json)
};
var result = await serviceClient.DirectMethods.InvokeAsync("deviceId", "$edgeAgent", request);

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."}

Metadata

Metadata

Assignees

No one assigned

    Labels

    IoTSDKTracks all IoT SDK issues across the boardbugSomething isn't working.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions