When I use the below REST API to query the issues in a specific sprint, there is an error returned: SyntaxError: Unexpected token < in JSON at position 0
/rest/agile/1.0/sprint/{sprintid}/issue?startAt=0&maxResults=50&fields=assignee,statuscategorychangedate,status
Anyone knows the possible reason why certian Jira Cloud sites get that error? Thanks.
BTW, the sites may be migrared from on-premise to Cloud.
NOTE: The execution time for this API call is 20 seconds.
const response = await api
.asUser()
.requestJira(route `/rest/agile/1.0/sprint/${SprintId}/issue?startAt=${startAt}&maxResults=${maxResults}&fields=assignee,${storyPointFieldId},statuscategorychangedate,status`);
const data = await response.json();
This looks very much like HTML being returned when you’re expecting a JSON response. That why the response.json() call fails. Most of the times when I encountered something like this, it turned out to be an authentication error, but it could also be something else.
I would suggest you change the last line to something like this and check what’s actually being returned:
const data = await response.text();
console.log(data);
Without the exact error message, there really isn’t a way to know for sure what’s going on. However, if I were to venture a guess, then maybe the sites that show the error do not include Jira Software? If I remember correctly, Jira Work Management does not include Sprints.
BTW, how do you get that observation or conclusion that all the 6 REST APIs have this issue? May I know if your Jira instance is migrated from on-premise Jira (e.g. Server or Data Center)?
Hi
No, my Jira wasn’t migrated. About the observation, we are developing a cloud app on Forge and tried to figure out where the errors come from in the console.
One issue to be aware of with Jira Software-specific APIs is that they do typically require additional scopes, not the typical read:jira-work scopes required by most other APIs.
@veloti & @YY1 if you’re seeing this issue for only a subset of Jira Cloud sites that your app is installed into, or you’re otherwise unable to resolve the issue, please raise an support request under the Report a bug category in our ECOHELP service desk with more specifics about your apps & Jira sites and our Developer Support team will endeavour to assist you.
Thanks @tpettersen I’ve raised one and got suggestion to add rate limiting logic. I’m struggling with the suggested solution now. Jira Service Management