Clarity task api returns invalid next link
search cancel

Clarity task api returns invalid next link

book

Article ID: 427298

calendar_today

Updated On:

Products

Clarity PPM On Premise Clarity PPM SaaS

Issue/Introduction

Using clarity's tasks REST API endpoint (ppm/rest/v1/tasks) to list all tasks assigned for a resource for timesheet purposes. The GET calls with the following filter returns a response with a valid first page (_self) and (_next) link which serves as pagination when resource id has more tasks than fit on one page (limit set to 5 in this example):

https://<clarity URL>/ppm/rest/v1/tasks?filter=((assignedResourcesFilter in (5060455)) and (isOpenForTE = true))&limit=5&fields=name,code,chargeCode,isOpenForTE,investmentId,lastUpdatedDate&objFilter=(tsAllAssignableTasks(resource=(5060455),timesheetId=(1)))

The response contains a pagination (_next ) link like:

https://<clarity URL>/ppm/rest/v1/tasks?filter=%28%28assignedResourcesFilter+in+%285060455%29%29+and+%28isOpenForTE+%3D+true%29%29&objFilter=%28tsAllAssignableTasks%28instSecObjCodes%3D%28%27cmn_team_inv%27%2C%27application%27%2C%27asset%27%2C%27idea%27%2C%27other%27%2C%27product%27%2C%27project%27%2C%27service%27%29%2CglbObjCodes%3D%28%27_NaN%27%29%2CuserId%3D%285083139%29%2Cresource%3D%285060455%29%2CtimesheetId%3D%281%29%29%29%7E%27%7E%28crossInvAssignees%28resources%3D%285060455%29%29%29%3A%3A%28%28assignedResourcesFilter+in+%285060455%29&fields=name%2Ccode%2CchargeCode%2CisOpenForTE%2CinvestmentId%2ClastUpdatedDate&limit=5&offset=5

When decoded:

https://<clarity URL>/ppm/rest/v1/tasks?filter=((assignedResourcesFilter in (5060455)) and (isOpenForTE = true))&objFilter=(tsAllAssignableTasks(instSecObjCodes=('cmn_team_inv','application','asset','idea','other','product','project','service'),glbObjCodes=('_NaN'),userId=(5083139),resource=(5060455),timesheetId=(1)))~'~(crossInvAssignees(resources=(5060455)))::((assignedResourcesFilter in (5060455)&fields=name,code,chargeCode,isOpenForTE,investmentId,lastUpdatedDate&limit=5&offset=5

Requesting this next link results in the following error message in API response. 

400

{
 "resourceId": null,
 "httpStatus": "400",
 "errorMessage": "API-1054 : Invalid object filter query. Object filter 'tsAllAssignableTasks' cannot use attribute 'instSecObjCodes' multiple times.",
 "errorCode": "api.duplicateObjFilterAttr"
}

Cause

When Clarity constructs pagination links for complex queries involving objfilter, it tries to preserves the state of that complex macro by re-encoding and at times leads to mangling of the _next link by duplicating attributes or double-encoding characters.. While clarity is able to parse the system generated _next link internally and handle pagination on the timesheet page to add assigned tasks, external calls need to adjusted to avoid the error.

If you observe the decoded link:

  • Truncation: The string ends abruptly without closing parentheses.

  • Internal Merging: Clarity attempted to "remember" your filter state by appending it to the objfilter using ::. This caused the parser to see the same security parameters twice, triggering the "cannot use attribute 'instSecObjCodes' multiple times" error.

https://<clarity URL>/ppm/rest/v1/tasks?filter=((assignedResourcesFilter in (5060455)) and (isOpenForTE = true))&objfilter=(tsAllAssignableTasks(instSecObjCodes=('cmn_team_inv','application','asset','idea','other','product','project','service'),glbObjCodes=('_NaN'),userId=(5083139),resource=(5060455),timesheetId=(1)))~'~(crossInvAssignees(resources=(5060455)))::((assignedResourcesFilter in (5060455)&fields=name,code,chargeCode,isOpenForTE,investmentId,lastUpdatedDate&limit=5&offset=5

Resolution

Clarity MUX is able to process the _next links and pagination works as expected with the MUX views. Here are the options recommended for external calls that is based on the _next link:

Option 1. The Clean Path (Standard Filter Only without objfilter)

Use the call that works with pagination. Since assignedResourcesFilter already brings back the tasks needed, objfilter can be removed. 

The reason the _next link works without the objfilter is that the standard filter parameter uses a relatively straightforward parser. However, the objfilter (like tsAllAssignableTasks) is a "Macro" that triggers complex, internal security joins.

Example:

GET https://<clarity URL>/ppm/rest/v1/tasks?fields=investmentName,name,phaseTaskName,status,startDate,finishDate,preventUnassignedTask,isOpenForTE,investmentId,isTaskAssignedToRes,isAssignmentOpenForTE,invAllowUnstaffedTimeEntry,_isFavorite&filter=(assignedResourcesFilter in (5024855))&sort=investmentName asc,name asc&limit=5

_next link returned in response

https://<clarity URL>/ppm/rest/v1/tasks?fields=investmentName,name,phaseTaskName,status,startDate,finishDate,preventUnassignedTask,isOpenForTE,investmentId,isTaskAssignedToRes,isAssignmentOpenForTE,invAllowUnstaffedTimeEntry,_isFavorite&filter=(assignedResourcesFilter in (5024855))&sort=investmentName asc,name asc&limit=5

GET call against the Decoded version of the _next link is working as expected:

http://<clarity URL>/ppm/rest/v1/tasks?fields=investmentName,name,phaseTaskName,status,startDate,finishDate,preventUnassignedTask,isOpenForTE,investmentId,isTaskAssignedToRes,isAssignmentOpenForTE,invAllowUnstaffedTimeEntry,_isFavorite&filter=(assignedResourcesFilter in (5024855))&sort=investmentName asc,name asc&limit=5

 

Option 2. The Manual offset Path (With objfilter)

Best Practice for Clarity Pagination If you must use the objfilter (e.g., for specific timesheet logic), do not use the _next link. Instead, use your code to manually increment the offset.

To avoid this issue follow this logic:

  1. Don't trust the objfilter in the _next link: The server often mangles it.

  2. Keep your original Query: Store your initial filter and objfilter strings in your script.

  3. Manual Offset: Simply take your working "First Page" URL and manually change the offset value to get the next page.

 

Page Base URL + Filter Logic Pagination Parameters
Page 1 .../tasks?filter=(...)&objfilter=(...) &limit=5&offset=0
Page 2 .../tasks?filter=(...)&objfilter=(...) &limit=5&offset=5
Page 3 .../tasks?filter=(...)&objfilter=(...) &limit=5&offset=10

To conclude If the Standard Filter version (Resource Filter only) gives you the data you need, stick with it. It is significantly more stable, handles pagination natively, and avoids the "Sensitive Character" bugs found for more complex objfilter macros.