I am trying to run a sentiment analysis using Power BI and Microsoft cognitive text analysis.
This is my code for the query.
(Source as table) as any =>
let
JsonRecords = Text.FromBinary(Json.FromValue(Source)),
JsonRequest = "{""documents"": " & JsonRecords & "}",
JsonContent = Text.ToBinary(JsonRequest, TextEncoding.Ascii),
Response =
Web.Contents("https://westcentralus.api.cognitive.microsoft.com/text/analytics/v2.0",
[
Headers = [#"Ocp-Apim-Subscription-Key"= APIKey,
#"Content-Type"="application/json", Accept="application/json"],
Content=JsonContent
]),
JsonResponse = Json.Document(Response,1252)
in
JsonResponse
As far as I'm concerned I did create my parameters correctly. I also double checked my key and API.
I receive this error:
An error occurred in the ‘’ query. DataSource.Error: Web.Contents failed to get contents from 'https://westcentralus.api.cognitive.microsoft.com/text/analytics/v2.0' (404): Resource Not Found Details: DataSourceKind=Web DataSourcePath=https://westcentralus.api.cognitive.microsoft.com/text/analytics/v2.0 Url=https://westcentralus.api.cognitive.microsoft.com/text/analytics/v2.0
This documentation indicates that POST
request is to a /sentiment
endpoint, so you should update the URL to https://westcentralus.api.cognitive.microsoft.com/text/analytics/v2.0/sentiment
.