Welcome to the fourth installment of our SData 2.0 series, where we explore the powerful capabilities of Sage CRM’s SData 2.0 API. If you haven't already, check out Part 1, Part 2, and Part 3 to get up to speed with querying, updating, and inserting records using the API.
In this article, we’ll focus on deleting records—a crucial aspect of data manipulation enabled by SData 2.0. Using RESTful DELETE operations, you can effectively remove data from your Sage CRM database.
Deleting records in Sage CRM using SData 2.0 follows a straightforward syntax, similar to querying records, but with the DELETE verb in the REST call.
Key points to remember:
Let’s begin by deleting a company record from Sage CRM. Suppose we need to delete the company with an ID of 1224.
DELETE http://{ServerName}/sdata/{InstallName}j/sagecrm2/-/Company('1224')
By sending this request via Postman or a similar tool, you should receive a blank response, indicating that the company record has been successfully deleted.
(no content)
The empty response confirms that the record has been successfully deleted from the system.
In this example, we will delete an email address associated with a specific company. To delete the email address, we first need to query the company to retrieve the Email ID.
To get the email address associated with company 1225, send the following request to retrieve the relevant details:
GET http://{ServerName}/sdata/{InstallName}j/sagecrm2/-/Company('1225')
The response will include the ID of the associated email record. Let’s assume the Email ID is 2111.
Now, we can delete the email record using the DELETE method and the Email ID retrieved earlier:
DELETE http://{ServerName}/sdata/{InstallName}j/sagecrm2/-/Email('2111')
Once you send this request, the response will be blank, indicating the email record has been successfully deleted.
(no content)
The DELETE functionality within SData 2.0 provides an efficient and powerful way to manage your Sage CRM data. Whether you're cleaning up outdated records or adjusting your database, the ability to delete records is an essential part of maintaining accurate and up-to-date information.
In the next post, we’ll dive deeper into even more advanced features of SData 2.0. If you have any questions or need further assistance, feel free to reach out!
Stay tuned for more insights in our SData 2.0 series.