Hi,
I would like to use the web call in Excel's Power Query in order to call an Infor LN availabe endpoint.
But I need an API key for that.
Did someone managed to do something similiar?
I had dabbled in this previously, and resurrected what I did that may help you.. Curious as to your progress.
let
// Replace these values with your ionapi credentials file. api_ti = "{mytenant}_DEV", api_cn = "KH Utility BE using KHeiman 27Mar24", api_ci = "{mytenant}_DEV~EwJ_oq0jan<<removed>>KK-axDGvKIeIg", api_cs = "fUtsw8zD_oCcuNIKlKA5eQQTxS7NXYNYe9ansU6<<removed>>S0g0owTwx69UWAsw", api_iu = ">xxmingle-ionapi.inforcloudsuite.com", api_pu = ">xxmingle-sso.inforcloudsuite.com:443/.../as/", api_oa = "authorization.oauth2", api_ot = "token.oauth2", api_or = "revoke_token.oauth2", api_ev = "U1478358101", api_saak = "{mytenant}_DEV#5a47or6Z4bve1b1otZxpIDoQf-<<removed>>Pi_7v249k6XpgpYUA", api_sask ="VVEmy<<removed>>N4n8Hnr8s7gOA",//// get a bearer token token_url = api_pu & api_ot, api_base_url = api_iu & api_ti & "OSPORTAL/admin/v1/info/status", api_qry_str = "", // example "?myparameter"
body="grant_type=password&client_id=" & api_ci & "&client_secret=" & api_cs & "&username=" & api_saak & "&password=" & api_sask , Source = Json.Document(Web.Contents(token_url, [ Headers = [#"Content-Type"="application/x-www-form-urlencoded"], Content=Text.ToBinary(body) ] ) ), bearer_token = Source[access_token],
refresh_token = Source[refresh_token] , token_type = Source[token_type] , expires_in = Source[expires_in] ,// API trace references trace_parent = Text.NewGuid() as text, trace_datetime = DateTime.FixedLocalNow() as datetime, trace_id = DateTime.ToText(trace_datetime,[Format="yyyy-MM-dd'T'HH:mm:ss'Z'", Culture="en-US"]),//// Call the URL and get response data= Json.Document(Web.Contents(api_iu & api_qry_str, [ Headers = [ #"Authorization"="Bearer "&bearer_token,#"Content-Type"="application/json", #"User-Agent"="KHPowerExcel",#"parent-id"=trace_parent,#"trace-id"=trace_id] ] ) ) in data //
I meant to add, that if you are doing repeated calls, you should use the refresh token once you get the initial bearer token.
In this example I was just calling once to get status as an example.
Hi. I'm pretty new to this. Are you using this in production? Were there any business security concerns of including the ionapi content inside the Power Query source?