Home > Software design >  Send and receive JSON content in Event Hub
Send and receive JSON content in Event Hub

Time:02-17

I am using below code to send content to Event Hub which is being read by Logic App . In Logic App when I select content-type as application/octet-stream, it works fine but I get Content body as encoded, and when I select application/json as content-type then it fails. How can I modify my content below so that my logic app reads the json sent from below code.

for (int i = 1; i <= numOfEvents; i  )
            {
                if (!eventBatch.TryAdd(new EventData(Encoding.UTF8.GetBytes("Event"))))
                {
                    // if it is too large for the batch
                    throw new Exception($"Event {i} is too large for the batch and cannot be sent.");
                }
            

CodePudding user response:

You can directly decode the content that is getting triggered from the event hub using decodeBase64() in your logic app. One of the workarounds that you can do is simply add a compose connector and use decodeBase64(triggerBody()?['ContentData']) for decoding your content.

Here is a screenshot of the logic app for your reference:

enter image description here

Output :-

enter image description here

  • Related