Passing Binary Data to REST

Passing Binary Data to REST

  

Team,

I am trying to upload an image (binary) to the Azure Cognitive Face Detection API, however, I am sorta stuck in figuring out how to pass binary in a JSON? I know you cant through JSON, so whats the solution? 

Hi Tanveer... 

I'd assume the API documentation will tell you what's the format of the received data?... in any case, you can always encode binary data in Base64, if that's the expected format: there are actions for that in the BinaryData extension. But I would expect the platform to take care of any necessary encoding if the webservice action receives a BinaryData input parameter...

Jorge Martins wrote:

Hi Tanveer... 

I'd assume the API documentation will tell you what's the format of the received data?... in any case, you can always encode binary data in Base64, if that's the expected format: there are actions for that in the BinaryData extension. But I would expect the platform to take care of any necessary encoding if the webservice action receives a BinaryData input parameter...

What I am trying to do is the following API: https://westcentralus.dev.cognitive.microsoft.com/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395236/console

With content-type: application/octet-stream

So I have very little control over how its getting parsed. 


Solution

Hi tanveer,

You are misunderstanding the API you are trying to use.

The face detection can work over an Image in two ways: URL and binary.

The json in the body of the requested is used when you want to send an URL to the API.

If you want to send the image binary instead, the body content will not be json, will be the binary.

Cheers,

Eduardo Jauch

Solution

Thank you, this helped. Woohoo. Thank you @Eduardo