function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Goran K.Goran K. 

Delete Contact trough Postman REST API

Hi, 

I have dowloaded Salesforce APIs for Postman where there are several DELETE commands. A simple one I am trying to perform is to delete a Contact in our test org. And in stead of Deleting the contact I am only retreiving it, or it looks so. 

I have DELETE command looking like bellow:
DELETE {{url}}/services/data/v51.0/sobjects/Contact/0033O00000aoFvCQAU 
and using Bearer Token. 

b.r.
Goran K.

Best Answer chosen by Goran K.
Goran K.Goran K.
I've finely found a solution to my problem.
Basically I was using Lightning API in stead of Classic Salesforce api.
So what i tried to do was
DELETE https://<my-org>.my.lightning.force.com/services/data/v51.0/sobjects/Contact/0033O00000aplCVQAY
while the correct call was:
DELETE https://<my-org>.my.salesforce.com/services/data/v51.0/sobjects/Contact/0033O00000aplCVQAY

I hope this helps someone. 

All Answers

SwethaSwetha (Salesforce Developers) 
HI Goran,
Can you change the URI to include the /composite/ and see if that helps
DELETE /services/data/vXX.X/composite/sobjects?ids=recordId
https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/resources_composite_sobjects_collections_delete.htm 
Thanks
Goran K.Goran K.

Hi Swetha and thaks for the quick answer.
Its strange. I change URI to {{urlbicxtest}}/services/data/v51.0/composite/sobjects?ids=0033O00000aoFvCQAU
and the response I get is this:

[
    {
        "errorCode": "METHOD_NOT_ALLOWED",
        "message": "HTTP Method 'GET' not allowed. Allowed are POST,PATCH,DELETE"
    }
]
User-added image

SwethaSwetha (Salesforce Developers) 
I tried the same URI via workbench through REST Explorer and could confirm records getting deleted

User-added imageChecking via postman too
Goran K.Goran K.
Workbench works for me two. I can even delete with bith URIs. Both mine and yours.
Can you try doing trough postman?

Thanks!
SwethaSwetha (Salesforce Developers) 
I could suceed with postman too
User-added image
User-added imageCan you clear the cookies and retry?

Also ensure the endpoint is HTTPS.See similar scenario: https://salesforce.stackexchange.com/questions/104360/publicly-exposed-rest-class-does-not-support-post-method

If this information helps, please mark the answer as best. Thank you
Goran K.Goran K.
Ok. Well it doesn't work for me. I tried with two different orgs and two different objects. One is Contact and the other is some custom object.
Could it be some API setting in Salesforce? I don't know.

User-added image

 
SwethaSwetha (Salesforce Developers) 
Instead of {{_endpoint}} can you try directly with your instance URL and see if that works?
Goran K.Goran K.
I still got the same:
[
    {
        "errorCode": "METHOD_NOT_ALLOWED",
        "message": "HTTP Method 'GET' not allowed. Allowed are POST,PATCH,DELETE"
    }
]
Goran K.Goran K.
And I am using HTTPS 
Goran K.Goran K.
Any other ideas @Swetha?? 

Could it be something with setup of the connected app? Or user or something else? I tried with different options in several orgs, but nothing seams to work.
Is it possible to export the workbench call somehow to JSON file?
SwethaSwetha (Salesforce Developers) 
As you mentioned earlier, it is specific to the postman tool. Any specific reason why you want to only use postman? Can you confirm you are using the latest version of postman?
Goran K.Goran K.
I've finely found a solution to my problem.
Basically I was using Lightning API in stead of Classic Salesforce api.
So what i tried to do was
DELETE https://<my-org>.my.lightning.force.com/services/data/v51.0/sobjects/Contact/0033O00000aplCVQAY
while the correct call was:
DELETE https://<my-org>.my.salesforce.com/services/data/v51.0/sobjects/Contact/0033O00000aplCVQAY

I hope this helps someone. 
This was selected as the best answer