Forum Discussion

runski's avatar
runski
Frequent Visitor
9 years ago

Enterprise Gateway and Text Analytics

Hi.

Can someone guide me on how to set up a connection to Text Analytics API using the Enterprise Gateway?

Thanks.

5 Replies

    • ivargjerde's avatar
      ivargjerde
      Advocate I

      We implemented the API in a Blank Query using the following code

       

      (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://westus.api.cognitive.microsoft.com/text/analytics/v2.0/sentiment",
                  [
                      Headers = [#"Ocp-Apim-Subscription-Key"= "Our API key",
                                 #"Content-Type"="application/json", Accept="application/json"],
                      Content=JsonContent
                  ]),
          JsonResponse = Json.Document(Response,1252)
      in
          JsonResponse

       

      We then call the Query from a table that contains the text we want to analyze. The text comes from our on-premise SQL server that we connect to through the Enterprise data gateway. When we try to enable refresh on the dataset we get the following error.

       

      Something went wrong.
       
      Failed to use the selected gateway. Please make sure the gateway is up and running and try again.
      Please try again later or contact support. If you contact support, please provide these details.
      Activity ID84912326-5530-51de-9f1b-04c74b35d761
      Request IDf3a597ca-2144-5f1c-9b80-623075143a83
      Correlation ID1422aa44-c7bc-1602-688c-872d0c2b6f0a
      Status code400
      TimeMon Oct 17 2016 10:52:42 GMT+0200 (Central European Daylight Time)
      Version13.0.1700.374
       
      If we delete the table that calls the query and republish the model refresh works fine. Any input on where we might be going wrong would be greatly appreciated!