SAP Knowledge Base Article - Public

3508796 - System Query Parameters for REST-API in V2

Symptom

We have adopted a different data transmission for APIs in CNS, where the XML data format of REST API is used instead of SOAP API in Sales and Service Version 2. 

You want to know about the query and commonly filters available for API Restful. 

Environment

SAP Sales Cloud and SAP Service Cloud Version 2

Reproducing the Issue

Use Case example: You want retrieve all details of a particular entity from an public Service within Service Cloud Version 2/Sales Cloud Version 2/Add-ons.

Reference: https://api.sap.com/package/SAPSalesServiceCloudV2/rest

Resolution

Systems Query ParametersDescription
$topIndicates page size.
$skipIndicates offset (number of items).
$searchIndicates the search expression for the collection.
$orderbyComma separated list of attribute names, attributed with ascending or descending.
$filterIndicates the filter expression which is a combination of resource attributes, values (literals), and operators.
$countReturn only the count of resources in collection.
$selectSelect specific attributes (or) nodes from the aggregate.
$excludeExclude specific attributes (or) nodes from the aggregate.
$queryIndicates the query (defaultset) to be used by the service.
$sourceidIt is used for copy and create with reference scenarios.  
$sourcetypeIt is used for create with reference scenarios. 

Filters ParametersOperatorExample
Equalseq$filter=field1 eq 10
Andand$filter=field1 eq 'A' and field2 eq 14
Oror$filter=countryCode eq 'ES' or countryCode eq 'US'
Less thanlt$filter=field1 lt 42
Greater thangt$filter=object1/field1 gt 42
Less than or Equal tole$filter=field1 le 42
Greater than or Equal toge$filter=field1 ge 42
Not equal tonefilter=field1 ne 42
Select a range of values

ge and le

$filter=field1 ge 42 and field1 le 39
$filter=field1 gt 42 and field1 lt 39
Notnot$filter=not(countryCode eq 'ES')
Parentheses Grouping(...)$filter=not(countryCode eq 'ES')
Starts Withsw$filter=city sw 'San'
Ends Withew$filter=city ew 'cisco'
Containsct$filter=city ct 'Fran'
Inin$filter=city in ('San Francisco', 'Tokyo')

See Also

A RESTful API is an application programming interface (API) that uses HTTP requests to GET, PUT, POST, and DELETE data. It is also referred to as a RESTful Web service, which is based on a representation state transfer (REST) architecture.

REST APIs support different HTTP methods:

  • GET

    The GET method requests the server to retrieve the data of the specified resource. For example, in the Reports API of the Concur Expense package, the GET /expense/reports method retrieves all reports.

  • POST

    The POST method requests the server to accept the entity or data enclosed in the request as a new subordinate of the Web resource identified by the URI (Uniform Resource Identifier). For example, in the Reports API of the Concur Expense package, the POST /expense/reports method creates a new report.

  • PUT

    The PUT method requests the server to store the enclosed entity or data under the supplied URI. If the URI refers to an existing resource, it is modified. If the URI does not point to an existing resource, then the server creates one with that URI. For example, in the Reports API of the Concur Expense package, the PUT /expense/reports/{id} method updates the report specified by the URI

  • DELETE

    The DELETE method deletes the specified resource.

  • PATCH

    The PATCH method modifies or applies partial modifications to a resource.

Keywords

rest;restapi;parameter;filter;cns , KBA , CEC-CRM-INT , Integration for SAP Sales/Service Cloud , How To

Product

SAP Sales Cloud and SAP Service Cloud Version 2 1.0