Search
Close this search box.

DELETE Requests

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

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

    

Do you need consulting from our experts?

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

Receive the latest news

Subscribe To our SAP Sales & Service Cloud Newsletter

Get notified about new articles