情绪分析Power BI

时间:2018-06-29 09:39:16

标签: powerbi text-analytics-api

我正在尝试使用Power BI和Microsoft认知文本分析进行情感分析。

这是我用于查询的代码。

    (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

就我而言,我确实正确创建了参数。我还仔细检查了我的密钥和API。

我收到此错误:

  

“”查询中发生错误。 DataSource.Error:Web.Contents   无法从中获取内容   'https://westcentralus.api.cognitive.microsoft.com/text/analytics/v2.0'   (404):找不到资源详细信息:       DataSourceKind = Web       DataSourcePath = https://westcentralus.api.cognitive.microsoft.com/text/analytics/v2.0       Url = https://westcentralus.api.cognitive.microsoft.com/text/analytics/v2.0

Here is a screenshot of what the data looks like if it helps

1 个答案:

答案 0 :(得分:0)

documentation表示POST请求是针对/sentiment端点的,因此您应将URL更新为https://westcentralus.api.cognitive.microsoft.com/text/analytics/v2.0/sentiment