Forum Discussion

Imraan's avatar
Imraan
Regular Visitor
8 years ago

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%20in%20(Defect,%20%22Prod%20Issue%20%22,%20%22SIT%20Defect%20%22,%20%22UAT%20Defect%22)&fields=field=fixVersion%2Csummary%2Cissuekey%2Cassignee%2Cissuekey%2Cassignee%2Creporter%2Cpriority%2Cstatus%2Ccomponents%2Cresolution%2Ccreated%2Ccustomfield_11324%2Ccustomfield_10833%2Ccustomfield_10836%2Ccustomfield_11317%2Ccustomfield_11312%2Ccustomfield_11307%2Ccustomfield_10200%2Ccustomfield_10609&maxResults=2&startAt="
& 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

  • Anonymous's avatar
    Anonymous
    Not applicable

    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

  • Imraan's avatar
    Imraan
    Regular Visitor

     Anonymous

     

    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%20%3D%20Impediment&&startAt="
    & 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