Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.
So im dealing with an Rest Api that has a 900 second expiration.
I have tried creating a function that could be called on once DateTime.LocalNow() > Expiration ( which is DateTime.LocalNow()+duration(0,0,0,900) upon receiving the first Auth token) that would push a new Auth token into a loop (because the data is paginated with a low limit of rows per a pull ... its 50). im needing to pull the entire data set which takes more then the 15 min time window the rest api allows. Any suggestions or ideas would be very helpful =D
The Error i get after 900 seconds is We couldn't authenticate with the credentials provided. Please try again
The current Fx im using to attempt to get the new Auth token is
(Authcode as text) =>
let
body2 = "*****",
Data=Json.Document(Web.Contents("https://xxxxxxx", [RelativePath= "xxxxxxxx" ,Headers=[#"Content-Type"="application/x-www-form-urlencoded"], Content=Text.ToBinary(body2)])),
FormatAsJson = Json.Document(Data),
access_token1 =Data[access_token],
access_tokenHeader= "Bearer "& access_token1
in if Authcode = access_tokenHeader then getNewAuth(Authcode) else access_tokenHeader
The code leading up to this looks like this
Source2 = if getTime() > Endtime then getNewAuth(Authcode)
else Authcode,
That line of code is withen another fx loop due to pagination
User | Count |
---|---|
93 | |
83 | |
77 | |
70 | |
65 |
User | Count |
---|---|
114 | |
101 | |
96 | |
65 | |
60 |