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

Data Days is here! Join us now for 60+ days of learning, challenges, and connection. Learn more

Reply
Snap
Frequent Visitor

Schedule refresh fail - API with token

Hi, 

 

I have followed some instructions on getting a dynamic token to pull some information from a webiste. The function sends my credentials in order to get a token. This token then gets used for other API request to pull information. It all works well in desktop but as soon as I publish to the service it fails and I can't refresh.

 

Query to get token:

Capture.JPG

 

Query to get information using the token:

Capture1.JPG

 

Error I get on the service when trying to manaually or schedule a refresh:

 

Snap_0-1620517080568.png

Any help will be appreciated

4 REPLIES 4
v-deddai1-msft
Community Support
Community Support

Hi @Snap ,

 

Please use something like:

 

Source = Json.Document(Web.Contents("xxxxxxxx", [
  RelativePath="api/accounts",
  Query=[token=#"Get Token"()]
 ]))

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Best Regards,

Dedmon Dai

Seems to still give me a smilar error. It refreshes in desktop but as soon as I publish (that works) and try to refresh it gives me the below error. 

Hi @Snap ,

 

Not very sure about your issue since I can't reproduce it in my environment.  I think may be you have contains password and username in the url directly in your token function. I suggest you refer to  https://chris.koester.io/index.php/2015/07/16/get-data-from-twitter-api-with-power-query/  to modify your code and try again.

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Best Regards,

Dedmon Dai

Anonymous
Not applicable

Helpful resources

Announcements
Fabric Data Days is here Carousel

Fabric Data Days 2026

Don't miss out on Data Days, June 15 through August 7. Learn Fabric, Power BI, SQL, AI and more.

May Power BI Update Carousel

Power BI Monthly Update - May 2026

Check out the May 2026 Power BI update to learn about new features.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.