Getting `Status Code:400 Bad Request` When calling Microsoft Azure Emotion API with data of type `Content-Type:application/octet-stream`

后端 未结 1 527
攒了一身酷
攒了一身酷 2021-01-28 05:17

I\'m trying to send data to Microsoft Cognitive Services\' Emotion API, in the form of Content-Type: application/octet-stream.

I\'m getting the Base64 strin

相关标签:
1条回答
  • 2021-01-28 06:09

    I was doing a very silly thing here. The API Documentation of the Emotion API here says that it needs data as binary image data.

    But I was still giving it as JSON. I simply changed the implementation of getUserEmotion method. Instead of

    return this.http.post(this.apiUrl, { "data": this.makeBlob(userImageBlob) }, { headers: headers });
    

    I used this

    return this.http.post(this.apiUrl, this.makeBlob(userImageBlob), { headers: headers });
    

    Hope this helps someone who's facing the same issue!

    0 讨论(0)
提交回复
热议问题