Azure Translation in VB

rpm
rpm used Ask the Experts™
on
I am trying, for the first time, to make use of Azure Cognitive Services, translation service.

I cannot find a simple example to use this in VB.net

Can anyone point me to, or send me, such an example?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Technical Specialist
Awarded 2017
Distinguished Expert 2018
Commented:
These cognitive services are just REST endpoints

Here is a call with CURL
curl -X POST "https://api.cognitive.microsofttranslator.com/translate?api-version=3.0&from=en&to=zh-Hans" -H "Ocp-Apim-Subscription-Key: <client-secret>" -H "Content-Type: application/json" -d "[{'Text':'Hello, what is your name?'}]"

Open in new window


Here are sample REST examples
https://www.example-code.com/vbnet/rest.asp
rpm

Author

Commented:
Thanks for your post, I started by trying your above URL directly in Chrome. I inserted my Key1 in place of <client-secret> and pasted the whole resulting URL into Chrome. This responded with:

{"code":405000,"message":"The request method is not supported for the requested resource."}

Am I doing something wrong, or cannot I simply use the URL in chrome?

I must admit to being a complete newbie on this sort of thing.
Shaun VermaakTechnical Specialist
Awarded 2017
Distinguished Expert 2018

Commented:
Am I doing something wrong, or cannot I simply use the URL in chrome?
Install Postman or the Postman Chrome extension. Some requests are POST etc. not GET. Browsers only do GET requests
Fundamentals of JavaScript

Learn the fundamentals of the popular programming language JavaScript so that you can explore the realm of web development.

rpm

Author

Commented:
Ok, that's progress!

I posted the URL, as a POST in Postman. This time I got ...

{
    "error": {
        "code": 401000,
        "message": "The request is not authorized because credentials are missing or invalid."
    }
}

Am I putting the wrong key in?
rpm

Author

Commented:
Has nobody got a simple example in VB for using the API, I am going around in circles?
Shaun VermaakTechnical Specialist
Awarded 2017
Distinguished Expert 2018

Commented:
Am I putting the wrong key in?
Yes, get a key from the Portal
rpm

Author

Commented:
Thanks for your help, with this help, I got there in the end!

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial