Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Pulling data from the API that serves pages using nextPageToken

Yugandhar Bandi
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
February 10, 2025

 

 

I'm trying to pull the data from the newest Jira cloud API (v3) and they produce a json that looks like this:

{

issues: [

1,

2,

3

], 

nextPageToken : "string"

}

 

nextPageToken is nullable, that is it is absent on the last page of the result.

 

I'm having trouble with the function that gets the next page which looks like this:

 

// Function to fetch data using next page token
FetchJiraData = (NextPageToken as nullable text) =>
let
ApiUrl = if NextPageToken = null then
BaseUrl & "jql=project=myproj&maxResults=" & Number.ToText(PageSize)
else
//NextPageToken, // Use nextPage URL
BaseUrl & "jql=project=myproj&maxResults=" & Number.ToText(PageSize) & "nextPageToken=" & NextPageToken, // Use nextPage URL
Source = Json.Document(Web.Contents(ApiUrl, headers)),

Issues = try Source[issues] otherwise {},
NextPageToken = try Source[nextPageToken] otherwise null

in
[Data = Issues, NextToken = NextPageToken]

 

When calling the function, I get

Expression.Error: We cannot convert a value of type Record to type Function.
Details:
Value=[Record]
Type=[Type]

 

Any help will be appreciated!

 

1 answer

0 votes
Tuncay Senturk _Snapbytes_
Community Champion
March 12, 2026

Hi @Yugandhar Bandi 

The error is caused by the function parameter NextPageToken with a variable of the same name inside the let block. You redefined a variable with the same name as a parameter.

use a different variable name instead of redefining NextPageToken.

ReturnedNextToken = try Source[nextPageToken] otherwise null

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events