Entity Filtering

Specify entity filters in the form of endpoint query parameters to restrict the contents of endpoint responses to objects that match particular criteria. For example, to ensure the /restapi/<resourcename> endpoint only returns objects with a status of Not Started, add a Status:eq:'Not Started' query parameter to the requested endpoint: /restapi/<resourcename>?Filter=Status:eq:'Not Started'.

The P6 REST API supports several entity filtering options. The following table lists supported entity filter operations:

Name Operator Description URL Encoded Operator Examples
Equals :eq: Excludes response objects that do not contain properties with values matching the value specified in the filter parameter. %3Aeq%3A

Only return objects with an ObjectId value of 1001:

Filter=ObjectId:eq:1001

URL encoded form: Filter=ObjectId%3Aeq%3A1001

Does not Equal != Only includes response objects that contain properties with values that do not match the value specified in the filter parameter. !%3D

Only return resources with ObjectId values that are not equal to 1001:

Filter=ObjectId!=1001

URL encoded form: Filter=ObjectId!%3D1001

Less than or Equal to :lte:

Include response objects that contain properties with values less than or equal to the value specified in the filter parameter.

This filter operation supports numeric and date values.

%3Alte%3A

Only return resources with ObjectId values less than or equal to 88578:

/restapi/activity?Fields=Name,ObjectId&Filter=ObjectId:gte:88578

URL encoded form: restapi/activity?Fields=Name,ObjectId&Filter=ObjectId%3Alte%3A88578

Greater than or Equal to :gte:

Include response objects that contain properties with values greater than or equal to the value specified in the filter parameter.

This filter operation supports numeric and date values.

%3Agte%3A

Only return resources with ObjectId values greater than or equal to 88578:

/restapi/activity?Fields=Name,ObjectId&Filter=ObjectId:gte:88578

URL encoded form: restapi/activity?Fields=Name,ObjectId&Filter=ObjectId%3Agte%3A88578

Less than :lt:

Include response objects that contain properties with values less than the value specified in the filter parameter.

This filter operation supports numeric and date values.

%3Alt%3A

Only return resources with ObjectId values less than 88578:

/restapi/activity?Fields=Name,ObjectId&Filter=ObjectId:lt:88578

URL encoded form: /restapi/activity?Fields=Name,ObjectId&Filter=ObjectId%3Alt%3A88578

Greater than :gt:

Include response objects that contain properties with values greater than the value specified in the filter parameter.

This filter operation supports numeric and date values.

%3Agt%3A

Only return resources with ObjectId values greater than 88578:

/restapi/activity?Fields=Name,ObjectId&Filter=ObjectId:gt:88578

URL encoded form: /restapi/activity?Fields=Name,ObjectId&Filter=ObjectId%3Agt%3A88578

Combining Filters

You can combine entity filters using logical operators. For example, the /restapi/activity?Filter=ObjectId:eq:88577 :and: Name :like: 'Ensure%' endpoint combines ObjectId and Name value filters using a logical AND. The following table lists supported logical operators for combining entity filters.

Name Operator Description Examples
AND :and: The logical AND operator restricts response objects to entities that match all specified filter values.

Only return objects with ObjectId values of 88577 and Name matching values of 'Ensure':

/restapi/activity?Fields=Name,ObjectId&Filter=ObjectId:eq:88577 :and: Name :like: 'Ensure%'

URL encoded form: /restapi/activity?Fields=Name,ObjectId&Filter=ObjectId%3Aeq%3A88577%20%3Aand%3A%20Name%20%3Alike%3A%20%27Ensure%25%27

OR :or: The logical OR operator restricts response objects to entities that match one or more of the specified filter values.

Only return objects with ObjectId values of 88577 or 88578:

/restapi/activity?Fields=Name,ObjectId&Filter=ObjectId:eq:88577 :or: ObjectId:eq:88578

URL encoded form: /restapi/activity?Fields=Name,ObjectId&Filter=ObjectId%3Aeq%3A88577%20%3Aor%3A%20ObjectId%3Aeq%3A88578

Wildcards

Use wildcard entity filters to limit response objects based on textual patterns. For example, the /restapi/activity?Fields=Name,ObjectId&Filter=Name :like: 'Act1%' endpoint returns resource objects containing a activityName value of "Act1" followed by any string. The following table lists supported entity filter wildcards:

Name Operator Description Examples
Any String :like:

The Any String wildcard matches any string value of one or more characters.

This filter operation only supports the string and enum data types.

You can only use a wildcard to match textual patterns within a string.

Find any values that start with "act":

/restapi/activity?Fields=Name,ObjectId&Filter=Name :like: 'act%'

URL encoded form: /restapi/activity?Fields=Name,ObjectId&Filter=Name%20%3Alike%3A%20%27act%25%27

 

Find any values that end with "act":

/restapi/activity?Fields=Name,ObjectId&Filter=Name :like: '%act'

URL encoded form: /restapi/activity?Fields=Name,ObjectId&Filter=Name%20%3Alike%3A%20%27%act25%27

 

Find any values that have "act" in any position:

/restapi/activity?Fields=Name,ObjectId&Filter=Name :like: '%act%'

URL encoded form: /restapi/activity?Fields=Name,ObjectId&Filter=Name%20%3Alike%3A%20%27%act%25%27