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
Mbeeman
Regular Visitor

Using $.ajax to get a Web API and receiving Token Literal expected

Hi All,

 

I am having a lot of trouble getting this Web APi to work in Power BI. I reached out to the company providing the API and they stated it was an issue with Power Query and not them... I recieve a Token Literal Expected error when trying to access the API provided below and have had no luck so far correcting the error. I have been trying to access it via the blank query function in power bi. Hopefully someone here is smarter than I am and can assist with this. I have intentially not provided the API Key, but can assure you it doesn't work even with the key input into the query.

 

$.ajax(
type: 'GET',
url: 'https://api.projectmanager.com/api/v3/project/list',
headers: {'apiKey': '[yourApiKey]'}
).done(function(data) {
log(data);
});

 

Thanks in advance!

 

3 REPLIES 3
lbendlin
Super User
Super User

Not just that, you need to completely rewrite the query using the Power Query M language.  You can't copy/paste DHTML code into M.

lbendlin
Super User
Super User

What have you tried?  You use Web.Contents() for GET requests , and you can switch to POST by providing a binary payload.

 

Show your Power Query.

Hi, I am posting the above query directly into my Power Query. Do I need to change it into a web.contents format in order to use the GET functionality?

 

Mbeeman_0-1627261947832.png

 

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.

Top Solution Authors
Top Kudoed Authors