Wednesday 17 May 2017

Microsoft cognitive services example in JavaScript

I'm trying to make work this very simple example of the Microsoft Cognitive Services in JavaScript but it's not working.

I don't know why. Can some one help me or provide a working example?

I've tried to make the code work both in node and browser (of course with the right modifications to the code).

I'm getting this error in node: "statusCode":404,"message":"Resource not found".

While if I run the code example [provided on the website][1] I get this error: "Access Denied (401): Access denied due to invalid subscription key "(which is weird cause I'm copying the precise key that has been provide to my in my account page).

const cognitiveServices = require('cognitive-services');

const computerVision = cognitiveServices.computerVision({
        API_KEY: "myAPIkey"
});
const parameters = {
    "language": "unk",
    "detectOrientation": "true",
    "content-type": "application/json"
};
const body = {
    "url": "https://upload.wikimedia.org/wikipedia/commons/2/23/Space_Needle_2011-07-04.jpg"
};

computerVision.ocr({
        parameters,
        body
})
.then((response) => {
        console.log('Got response', response);
})
.catch((err) => {
        console.error('Encountered error making request:', err);
});



via Jack

No comments:

Post a Comment