0

I m calling Microsoft Face API for detecting the face in an image. While loading an image from local , I always get an error as below

{ code: 'InvalidImageSize',
  message: 'Image size is too small.' }

But using the same image via URL , its working fine.

const fs = require("fs");
const axios = require("axios");

axios({
    method : "post",
    url : " https://westcentralus.api.cognitive.microsoft.com/face/v1.0/detect?returnFaceId=true",
    headers : {
        'Content-Type': 'application/octet-stream',
        "Ocp-Apim-Subscription-Key" : "2da8e41a647c4079b2f9a6XXXXXXXXX"
    },
    body : fs.readFileSync("./photos/shiva3.jpeg").toString("base64")
}).then((res)=>{
    console.log("Response");
    console.log(res.data);
}).catch((err)=>{
    console.log(err.response.data.error);
})
g.shiva
  • 1
  • 2

1 Answers1

0

I have fixed the issue by calling default function in the axios.

const axios = require("axios").default;

g.shiva
  • 1
  • 2