Tuesday, May 11, 2021

Power Query - Connect API REST API Bearer

 

FNC_Access_Token

() => 

let

    url = "https://XPTO_SITE_TOKEN",

    body  = "{ ""user"": ""XPTO_USER"", ""pwd"": ""XPTO_PASS""} ",

    AccessToken = Json.Document(Web.Contents(url, [Headers=[#"Content-Type"="application/json"], Content=Text.ToBinary(body)])),

    access_token = AccessToken[token]

in

    access_token


FNC_Table_Prep

let

  // Get_Data

  Query = () => let

    Source = Json.Document(Web.Contents("XPTO_SITE_SEARCH", [Headers=[Authorization="Bearer " & Fnc_Access_Token()]])),

    #"Converted to Table" = Record.ToTable(Source),

    Value = #"Converted to Table"{4}[Value]

in

    Value

in

  Query


DIM_Table

let

    Source = Fnc_Table_Prep(),

    #"Converted to Table" = Table.FromList(Source, Splitter.SplitByNothing(), null, null, ExtraValues.Error),

    #"Expanded Column1" = Table.ExpandRecordColumn(#"Converted to Table", "Column1", {"_id", "user", "phone", "profile", "hLastUpdate", "active", "activationCode", "userName", "birthday", "gender", "followingCategories", "isProfileComplete", "name", "dob"}, {"_id", "user", "phone", "profile", "hLastUpdate", "active", "activationCode", "userName", "birthday", "gender", "followingCategories", "isProfileComplete", "name", "dob"})

in

    #"Expanded Column1"


No comments:

Post a Comment

Power BI APP - Delete or Unpublish

 UNPUBLISH DELETE