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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
Imraan
Regular Visitor

token literal expected

Hi Guys, 

 

I am getting a "token literal expected" error in my I-Fetchpages query and am not sure how to deal with it. I am calling a web api and trying to write a do while loop. 

 

Here are the two queries:

 

I-Fetchpage Query

(startAs as number) as table=>

let
contents = Web.Contents("https://jira.vitalityservicing.com/rest/api/latest/search?jql=project%20=%20VA%20AND%20issuetype%20i..."
& Number.ToText(startAs)),
json = Json.Document(contents),
Value = json[issues],
table = Table.FromList(Value, Splitter.SplitByNothing(), null, null, ExtraValues.Error)

in
table

 

I-Fetchpages Query

= let
GeneratedList =
List.Generate(
()=> [Result = try i-FetchPage(1) otherwise null, startAt = 0],
each [Result] <> null,
each [Result = try FetchPage([startAt]+51) otherwise null, startAt =([startAt]+51),
each [Result]),
in
GeneratedList

 

2 REPLIES 2
Imraan
Regular Visitor

 @v-yuezhe-msft

 

Hi Lydia,

 

Thank you for the help. I applied your changes and a few of my own. The query was great and I get my results however that the while loop is not terminating when it is null and pardon the pun I am stuck in a loop: )

 

Here are the queries with your changes and a few of mine:

Query 1 - iFetchpage

(startAs as number) =>

let
contents = Web.Contents("https://jira.vitalityservicing.com/rest/api/latest/search?jql=project%20%3D%20VA%20AND%20issuetype%2..."
& Number.ToText(startAs)),
json = Json.Document(contents),
issues = json[issues]
in
issues

 

Query 2 - iFetchpages

 let
iFetchpages = List.Generate(
()=> [Result = try iFetchpage(1) otherwise null, startAt = 0],
each [Result] <> null,
each [Result = try iFetchpage([startAt]+51) otherwise null, startAt = [startAt]+51],
each [Result]),
toTable = Table.FromList(iFetchpages, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
level1 = Table.ExpandListColumn(toTable, "Column1")
in
level1

 

Thanks again for the assistant.

 

Kind regards

 

Imraan

v-yuezhe-msft
Employee
Employee

@Imraan,

Do you get the above error in Advanced Editor? If so, when you click show error after the error message, which syntax does Power Query lead you to?

In your I-Fetchpages Query, it seems that there is an extra comma after "each [Result]),", change your code to the following and check if the error goes away,

= let
GeneratedList =
List.Generate(
()=> [Result = try i-FetchPage(1) otherwise null, startAt = 0],
each [Result] <> null,
each [Result = try FetchPage([startAt]+51) otherwise null, startAt =([startAt]+51),
each [Result])
in
GeneratedList




Regards,
Lydia

Community Support Team _ Lydia Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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