Digital twin telemetry API not working

Sukun Jain 0 Reputation points
2024-01-08T18:31:58.74+00:00

I am trying to hit the telemetry Post API https://XXXX.api.weu.digitaltwins.azure.net/digitaltwins/SimpleTwin/telemetry?api-version=2020-10-31

Whenever I am trying to hit the above API either with power automate or through postman the request is not getting completed and getting below error on postman.

Error: socket hang up

▶Request Headers

Content-Type: application/json

Message-Id: e5ca50dd-ca31-4fae-8d84-3af5a72b10c5

Azure Digital Twins
Azure Digital Twins
An Azure platform that is used to create digital representations of real-world things, places, business processes, and people.
231 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Sander van de Velde | MVP 33,136 Reputation points MVP
    2024-01-08T21:36:14.2733333+00:00

    Hello @Sukun Jain ,

    welcome to this moderated Azure community forum.

    It seems you want to execute this command to send telemetry.

    I'm not sure what exception you get.

    Have you tried this Postman tutorial?

    Notice you need to create a bearer token first to get this working. See also the prerequisites.

    It is recommended to use the Azure Digital Twins SDK (here is an example found on GitHub).


    If the response helped, do "Accept Answer". If it doesn't work, please let us know the progress. All community members with similar issues will benefit by doing so. Your contribution is highly appreciated.


  2. LeelaRajeshSayana-MSFT 16,046 Reputation points
    2024-01-08T22:19:21.6+00:00

    Hi @Sukun Jain Greetings! Welcome to Microsoft Q&A forum. Thank you for posting this question here.

    I have tested the API Send Telemetry using the Postman and here is how I could send the telemetry.

    1. I was prompted to include the Content_Length attribute in the header section. Please find the below image User's image
    2. The Content Length attribute has to be set based on your body length. For example, the below body request has content length of 20.
    {
        "temp": 59
    }
    
        For a different twin id with a different property name, I have found the Content-Length 33 to work. Here is my         JSON body for this.
    
    {
        "Level_of_Material": 71
    }
    
    
    

    As Sander pointed, you would also need to add Bearer token under the authorization OAuth 2.0 type. Please refer the Call Azure Digital Twins API with Postman for more details on this.

    Kindly note that the content length should match the number of bytes in the request body. If it set to a higher value, I have observed that request keeps running and eventually the connection gets closed.

    If your request is successful, you would see a 204 response as below

    User's image

    Please also note that the telemetry data cannot be viewed directly on the Azure Digital Twin explorer. Only property values get stored on the Digital Twin state information.

    To monitor the telemetry messages, you would have to an event handler to capture Digital Twin Telemetry Message event triggered by the Digital Twin. Kindly refer to the Model Attributes of DTDL for more information on this.

    Hope this helps! Please let us know if you have any additional questions or need further clarification.


    If the response helped, please do click Accept Answer and Yes for the answer provided. Doing so would help other community members with similar issue identify the solution. I highly appreciate your contribution to the community.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.