Olaf H-- on Fri, 10 Jun 2016 16:21:48

I am currently trying to send an image with JS from a canvas to the face api and fail with the binary image encoding.

Does anyone have some more data but:

use contentType: "application/octet-steam" and put the binary image data in the body

I have tried using canvas.toDataURL and removing the type/encoding part at the beginning, then base64-decoding the remaining base64-encoded string.

The result remains the same even after various variations (encoded, not-encoded, URL and toDataURL information as JSON), nothing seems to work. The best I get is a

400 Bad Request "{"error":{"code":"InvalidImage","message":"Decoding error, image format unsupported."}}" Error.

Any hints?



cthrash99 on Fri, 10 Jun 2016 17:32:31

You need to serialize the blob.  Although this answer is for the Vision API, the same principle applies for Face:

Olaf H-- on Sun, 12 Jun 2016 10:00:38

Thanks, that did it. I should have noticed that the request binary data didn't look like the original expected jpeg or png format (initial byte sequence).