OData API
DELETE Requests
The OData API gives you the possibility to delete objects from SAP Sales Cloud. Please note here that it is not possible do delete every business object. This post helps you to understand how this works and what restrictions there are
Navigation for OData API
1. Test SAP Sales Cloud OData API with Postman 1.1. OData 1.2. Postman 2. GET Requests 2.1. SAP Sales Cloud Object Collections 2.2 Metadata 2.2.1. Principle 2.2.2. Attributes 2.2.3. SAP-Attributes 2.3. Work with Parameters 2.3.1. Filter 2.3.2. Work with Dates and Datetimes 2.3.3. Orderby 2.3.4. Top 2.3.5. Skip 2.3.6. Format 2.3.7. Select 2.3.8. Count 2.3.9. Inlinecount 2.3.10. Expand 2.4. Examples of GET Requests 2.5. Build OData Queries for Reports 3. X-CSRF-Token 4. POST Request for creating 4.1. Single POST Request 4.2. Create multiple entries with $batch 5. PATCH Request for updating 5.1. Single PATCH Request 5.2. Change multiple entries with $batch 6. DELETE Requests 7. OData Monitor 8. OData Service Explorer 9. Enable customized fields for the API interface 10. Connect Mircosoft Power BI® with SAP Sales Cloud API 11. Deep Links for URL to SAP Sales Cloud Objects
With DELETE you have the possibility to delete objects from the SAP Sales Cloud. You always delete the objects with reference to the object ID, which is assigned once to an object. A DELETE request consists of three parts: The Request URL to API, the Collection and the ObjectID. Die ObjectID has to be noted in the request in brackets and apostrophes.
In SAP Sales Cloud it is not possible to delete every object. For example, accounts and contact persons cannot be deleted. At the same time, the approach is that if objects – which could be deleted – cannot be deleted if they already have a completed status. Check again following website to check which HTTP Method is allowed per object: OData Documentation (sap.com).
Basically there are only three different answers to your DELETE request. The first would be that the object with the specified object ID does not exist. The second response would be that it is not possible to delete this object and the third would be a response that is empty – symbolizing that the deletion was successful.
Response for: Object does not exist
<?xml version="1.0" encoding="utf-8"?> <error xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"> <code>ERROR</code> <message xml:lang="en">Delete not possible; object does not exist</message> </error>
Response for: Deleting not possible
<?xml version="1.0" encoding="utf-8"?> <error xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"> <code>ERROR</code> <message xml:lang="en">No delete authorization. Please contact your administrator.</message> </error>
Response for: Deleting successfully
As a case example it is tried to delete two visits. The visit with the ID 12385 has the status Completed and the visit with the ID 12386 has the status Open. You can already see in the action column that the delete icon for the visit with the ID 12835 is not present. As before, deleting completed objects is not possible; nevertheless, you should be able to see the behavior in this example.
First a GET request is executed, to get the ObjectID of both visits. The or function is used for both IDs in this request.
After you have exported the two object IDs for the visits through the GET request, you can now perform the DELETE request. First you have to insert the x-csrf-token in the header of the delete request.
Response for ID 12385: Error
<?xml version="1.0" encoding="utf-8"?> <error xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"> <code>ERROR</code> <message xml:lang="en">No delete authorization. Please contact your administrator.</message> </error>
Response for ID 12386: Success
The Customer Experience team at Camelot ITLab deals with exciting and challenging CRM related topics every day and serves a large portfolio of different customers from a wide range of industries. Trust in this collaboration and feel free to contact us at tlil@camelot-itlab.com.
Was this article helpful?
If you like our content we would highly appreciate your review on Trustpilot
#SAP C4C #SAP Cloud 4 Customer #Cloud 4 Customer #Cloud for Customer #SAP Sales Cloud #Sales Cloud #OData #API #Request #Postman #DELTERequest #Delete