Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
JakeSky
New Member

Rest Api has 15 min time out and i need to generate a new Auth token with pagination of 50 rows per

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


0 REPLIES 0

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.