Forum Discussion
Calling Azure ML Web Service from Power BI
My code to call the Cognitive Services API looks as follows:
(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"= "MY KEY",
#"Content-Type"="application/json", Accept="application/json"],
Content=JsonContent
]),
JsonResponse = Json.Document(Response,1252)
in
JsonResponseSince the Azure ML web service gives a url and key, I figured it would be possible to call it similar to the call above. However, the structure of the call and the required headers is a bit different, and trying to figure out the required pieces from the Azure ML web service API page is difficult.
Any thoughts?
dkay84_PowerBI wrote:
My code to call the Cognitive Services API looks as follows:
(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"= "MY KEY", #"Content-Type"="application/json", Accept="application/json"], Content=JsonContent ]), JsonResponse = Json.Document(Response,1252) in JsonResponseSince the Azure ML web service gives a url and key, I figured it would be possible to call it similar to the call above. However, the structure of the call and the required headers is a bit different, and trying to figure out the required pieces from the Azure ML web service API page is difficult.
Any thoughts?
As far as I know, http request is not language-specific, so either Power Query or any other language can send a request with proper request header. In your case, as you don't know how to apply the url and key, which is actually Azure ML specific, then I suggest you firstly ask a question like "how to call the Azure ML web service API" in the dedicated Azure ML forum, then transplant the answer to Power Query.
- ASHOKKPIN8 years agoResolver I
dkay84_PowerBI - this code works only in desktop right? not in powerbi.com