0

Http GET request including a WRAP authorisation header

I want to pull information from a timesheet web application - Dovico which has an api.

The request works in Postman and powerbi so I'm pretty sure its my code below with regards to the Authorization header. The response is "server failed to authenticate - unauthorised.

Dovico API doc: https://www.dovico.com/developer/API_doc/#t=API_calls_older%2FEmployees_v5.html

 

let mykey := "client=nkgbvldfglknfdl&user_token=dkjbgkdfhkl"
let response := do as server
http("GET", "https://api.dovico.com/Employees/?version=5", {
Authorization: "WRAP access_token=" + mykey,
'Content-Type': "application/json"
})
end;

if response.error then
alert(text(response.error))
else
alert(text(response.result))
end

3 replies

null
    • Gunther.1
    • 4 yrs ago
    • Reported - view

    In compare to the documentaion you have "client=" in your Token. >>"client=nkgbvldfglknfdl&user_token=dkjbgkdfhkl"

    • Fergal_O_Mahony
    • 4 yrs ago
    • Reported - view

    Thanks but that is the correct format for the Dovico API call 

    https://www.dovico.com/developer/API_doc/#t=API_calls_older%2FEmployees_v5.html

    • Fergal_O_Mahony
    • 4 yrs ago
    • Reported - view

    Solution found, thanks to Ninox.

    Need to pack the token in triple quotes.

     

    Working code below for anyone in future.

    let mykey := """client=nkgbvldfglknfdl&user_token=dkjbgkdfhkl"""
    let response := do as server
    http("GET", "https://api.dovico.com/Employees/?version=5", {
    Authorization: "WRAP access_token=" + mykey,
    'Accept': "application/json"
    })
    end;

     

    if response.error then
    alert(text(response.error))
    else
    alert(text(response.result))
    end

Content aside

  • 4 yrs agoLast active
  • 3Replies
  • 1126Views