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 Parameters | Description |
$top | Indicates page size. |
$skip | Indicates offset (number of items). |
$search | Indicates the search expression for the collection. |
$orderby | Comma separated list of attribute names, attributed with ascending or descending. |
$filter | Indicates the filter expression which is a combination of resource attributes, values (literals), and operators. |
$count | Return only the count of resources in collection. |
$select | Select specific attributes (or) nodes from the aggregate. |
$exclude | Exclude specific attributes (or) nodes from the aggregate. |
$query | Indicates the query (defaultset) to be used by the service. |
$sourceid | It is used for copy and create with reference scenarios. |
$sourcetype | It is used for create with reference scenarios. |
Filters Parameters | Operator | Example |
Equals | eq | $filter=field1 eq 10 |
And | and | $filter=field1 eq 'A' and field2 eq 14 |
Or | or | $filter=countryCode eq 'ES' or countryCode eq 'US' |
Less than | lt | $filter=field1 lt 42 |
Greater than | gt | $filter=object1/field1 gt 42 |
Less than or Equal to | le | $filter=field1 le 42 |
Greater than or Equal to | ge | $filter=field1 ge 42 |
Not equal to | ne | filter=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 |
Not | not | $filter=not(countryCode eq 'ES') |
Parentheses Grouping | (...) | $filter=not(countryCode eq 'ES') |
Starts With | sw | $filter=city sw 'San' |
Ends With | ew | $filter=city ew 'cisco' |
Contains | ct | $filter=city ct 'Fran' |
In | in | $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