Troubleshooting REST API issues

401 error (authentication error)

Possible reasonSolution
Wrong URLMake sure you're using real URL of your account, and not https://restapi.tpondemand.com/, https://md5.tpondemand.com/, or any other URL from the examples
Wrong tokenMake sure you've copied the token completely, without leaving out any symbols
Mix up of token and personal tokenDepending what what kind of token you've generated, make sure you're either using token or access_token parameter
SSO is enabledhttps://www.targetprocess.com/guide/settings/sso/single-sign-on-in-targetprocess/#REST_API_usage

Incomplete result

Possible reasonSolution
Lack of pagingIf you do not specify take parameter, you'll only get 25 items. Use paging to get up to 1000 items per API call with APIv1 or APIv2.
Some field are empty and you're using APIv2With APIv2 if the field is empty, it will not be present in the response at all
You're not specifying which fields you'd like to pullIf you do not specify include in APIv1 or select in APIv2, only some basic fields be returned in the response. Please make sure to enumerate all the fields that you'd like to get
Mix up of APIv1 and APIv2 syntaxIf you make APIv1 query, and you use API2 parameter select, it will be ignored. The same goes for API2 query with APIv1 selector include. Please make sure you're using appropriate the syntax for your API version.
Using or in APIv1 filterIf you try to combine two conditions with or in APIv1, only the first one will be applied. or in filters is only supported in APIv2.
Pulling two fields with the same name with APIv2For example: select={id,project.id}
It will try to pull two fields - id of the entity, and id of its project - with the same name id
Solution is to define a custom name for at least one of them (or both of them):
select={entityId:id,project.id}
select={id,projectId:project.id}
select={entityId:id,projectId:project.id}

500 error (bad request) - for GET requests

🚧

Always double-check the structure of data (field names, object names, collection names, connections between different object) in meta: https://md5.tpondemand.com/api/v1/index/meta

Possible reasonSolution
Mix up of APIv1 and APIv2 syntaxAPIv1 and APIv2 have different syntax. For example, to filter an item by Project in APIv1 we would use where=(project.name eq "Mobile"), while in APIv2 it would be where=(project.name="Mobile"). Please make sure you're using appropriate the syntax for your API version.
Using a term instead of the real entity name, e.g trying to pull Portfolio instead of Project (error message: "Property 'Portfolio' does not exist in 'UserStory'.")Make sure you're using real entity type names, and not terms. You should get the name of the field that not exist (the term) in the response.
Pulling a field that does not exist (error message: "Property 'field' does not exist in 'UserStory'.")Make sure you only pull the fields that actually exist in this entity. You should get the name of the field that not exist in the response.
Using invalid quotes (very popular among Mac users)Make sure you're only using ' or " as quotes, and never ` or any other type of quotes.
Using a complex selector in APIv2 without defining a custom name for it (error message: "Expression is missing an 'as' clause.")Example: select={id,name,Comments.Where(Owner.Kind="User").Max(CreateDate)}
Solution: define a custom name
select={id,name,lastcommented:Comments.Where(Owner.Kind="User").Max(CreateDate)}
Trying to aggregate an aggregation (reaching for a collection of a collection)Examples:
select={effort:UserStories.Sum(Tasks.Sum(Effort))}
select={maxdate:UserStories.Max(Tasks.Max(PlannedEndDate))}
select={count:UserStories.Sum(Tasks.Count)}
Solution: create a custom field and a metric and store the intermediate result there

500 error (bad request) - for POST requests

🚧

Always double-check the structure of data (field names, object names, collection names, connections between different object) in meta: https://md5.tpondemand.com/api/v1/index/meta

Possible reasonSolution
Using a term instead of the real entity nameMake sure you're using real entity type names, and not terms.
Trying to set an object (like EntityState, Release, Project, Team, etc.) using its name (instead of its ID), e.g.
EntityState:"Done"
Always use ID to set an object value:
EntityState:{Id:123}
If you do not know its ID - make GET API call to put it beforehand.
Trying to set a collection (like Assigned Teams, Assignments, Comments) incorrectly, e.g.
AssignedTeams:"Team Alpha"
AssignedTeams:{Id:123}
Use an array to set a collection. Inside this array every value is an object, so it has to be set using its ID:
AssignedTeams:[{Team:{Id:123}}]

403 error (not allowed)

Make sure that the user that you're using for Authentication have permission to perform the action that you're trying to do: https://www.targetprocess.com/guide/settings/users-roles-permissions/roles-permissions/