Hello there
So I created a web service experiment that I successfully tested it through calling it via Excel.
Now I would like to call it via Power bI but I dont know how to compose my content.
let
Score= (sp1 as any, sp2 as any, Religion as any, Marital as any, Gender as any, LiveAlone as any, Age as any, HasNeeds as any) =>
let
//note: these should be private, these serviceuri and servicekey will not be guaranteed to work, use your own and be careful when sharing!
serviceUri="azuremlserviceuri",
serviceKey="mykey"
PostContents= "
{
""Results"": {
""output1"": {
// ""type"": ""DataTable"",
""value"": {
""ColumnNames"": [
""sp1"": """&sp1&""",
""sp2"": """&sp2&""",
""Religion"": """&Religion&""",
""Marital"": """&Marital&""",
""Gender"": """&Gender&""",
""LiveAlone"": """&LiveAlone&""",
""Age"": """&Age&""",
""HasNeeds"": """&HasNeeds&"""
},
""GlobalParameters"": {}
}
}
",
//Define Wait function
Wait = (seconds as number, action as function) =>
if (List.Count(
List.Generate(
() => DateTimeZone.LocalNow() + #duration(0,0,0,seconds),
(x) => DateTimeZone.LocalNow() < x,
(x) => x)
) = 0)
then null else action()
//Call Wait function to wait 5 seconds
//then return the current time again
,
Source=Wait ( 0.05, () => Web.Contents(serviceUri,
[Content=Text.ToBinary(PostContents),
Headers=[Authorization="Bearer "&serviceKey,#"Content-Type"="application/json; charset=utf-8"]])),
#"Imported JSON" = Json.Document(Source),
#"Table from List" = Table.FromList(#"Imported JSON", Splitter.SplitByNothing(), null, null, ExtraValues.Error),
#"Transposed Table" = Table.Transpose(#"Table from List")
in
#"Transposed Table"
in Score
Then I got an error message "We cannot apply operator & to types Text and Number."
Where did i go wrong? Please could you assist?
Thank you very much in advance.