In the case when your IoTC App is NOT a legacy application, you can use a preview IoTC App (which is a CapabilityModel driven model type) with the REST APIs support for calling your device. Currently preview version doesn't have a feature what you are trying achieved, such as sending a C2D message to the device.
The IoTC preview supports only calling the device method - Execute Command.
The following screen snippets demonstrated this feature. For this example, I am using my Azure IoT Hub Tester, where the virtual devices are using the MQTT protocol directly to the underlying IoT Hub of the IoT Central App.
I have created a free IoT Central App with the AzureKit ESP32 template, registered and provisioned for device1 and connected from the Azure IoT Hub Tester:
Showing a command echo PnP model:
Invoking a command echo by REST POST call. Note, that the Authorization sastoken must be created in the Administration/API tokens page.
- The device1 received the direct call and than published its response (note, that this screen was not snipped for its short response time limit). The following screen snippet shows a complete sync REST call with the device1. Note, that this preview version didn't handle the response payload based on the mentioned document and PnP model.
- Finally, this screen snippet shows the history of this command action via the REST:
Note, that there is also missing the response object from the device like is described in the CapabilityModel schema.
UPDATE
I have added the missing screen snippet on the device side when the method echo has been invoked:
As you can see the above picture, the device received the REST POST payload and its published response back to the invoker based on the PnP model schema.
UPDATE 2
The following screen snippets demonstrated invoking a command upgrade for device4. Note, that the device4 is a PnP device created from the template SmartConnect FM-201 IoT Gateway.
The device4 received a message on the direct method upgrade:
The device4 sent the response back to the invoker and IoTC app. The following picture shows its history:
Notice again, there is missing a response object in the REST response and also in the IoTC App. I hope, this is a bug in this preview version and it will fix it soon to follow up the CapabilityModel schema.