Forum Discussion

darko861's avatar
darko861
Icon for Resolver II rankResolver II
2 years ago
Solved

Connecting to API error message

Hi all   I'm writing to seek assistance with connecting to the HiBOB HR system via its REST API. I'm currently attempting to modify the existing code to utilize the 'Authorization as Headers' metho...
  • darko861's avatar
    2 years ago

    Hi,

    After thorough testing, I determined that this method is the most effective, as it consistently produces the desired outcome.

     

     

    (id as text)=>

    let
    apiKey = "x000xxx000000x", username = "Basic XXX-0000",
    password = "x000xxx000000x",
    auth = "Basic " & Binary.ToText(Text.ToBinary(username & ":" & password), BinaryEncoding.Base64),
    apiUrl = "https://api.hibob.com",
    query = "/v1/people/id/employment",
    url = apiUrl,
    headers = [ #"Authorization" = auth, #"APIKey" = apiKey ],
    Source = Json.Document(Web.Contents(url,
    [
    RelativePath = "/v1/people/" & id & "/employment",
    Headers=[#"Authorization" = auth, #"APIKey" = apiKey ]

    ]))
    in
    Source