I am trying to writing a Qt based REST client that will communicate with Microsoft Cognitive Token Service using my Subscription-Key and get an authentication token which later I can use for establishing connection with Microsoft Cognitive Services API.
Authentication Token API documentation: http://docs.microsofttranslator.com/oauth-token.html
The following is my code:
QByteArray jsonString = "{\"Ocp-Apim-Subscription-Key\":\"***********************"}";
QUrl serviceURL("https://api.cognitive.microsoft.com/sts/v1.0/issueToken");
QNetworkRequest request(serviceURL);
request.setRawHeader("Content-Type", "application/json")
QNetworkAccessManager *manager = new QNetworkAccessManager(this);
QNetworkReply *reply = manager->post(request, jsonString);
qDebug() << reply->errorString();
Error:
unknown error
The above code always returns unknown error. I would appreciate someone point me in the right direction for fixing this problem.
Thank you.