+ Start a Discussion
AgrajAgraj 

Create Lead REST API throwing ENTITY_IS_DELETED error when creating a deleted lead again

Hello all,

 

I'm trying to create a lead using the Force.com REST API and able to do so successfully.

 

Now, I go ahead and delete that lead from Salesforce. 

 

If I try to create the same lead again via API, then it gives the following error:

[{"fields":[],"message":"entity is deleted","errorCode":"ENTITY_IS_DELETED"}]

 

I also tried deleting the lead from Recycle Bin in Salesforce, but that didn't helped.

 

Please let me know what I'm doing wrong.

Best Answer chosen by Admin (Salesforce Developers) 
AgrajAgraj

Thanks for all the replies.

 

The problem was in my code. It was sending a PATCH request to /services/data/v20.0/sobjects/Lead/[Lead_ID] when Lead_ID was deleted. I tried sending POST to /services/data/v20.0/sobjects/Lead/ with new Lead information and it worked. 

 

Sorry for the inconvenience caused.

All Answers

SuperfellSuperfell

It sounds like you may have a custom trigger on leads that is doing de-dupe, and it is flagging the error.

AgrajAgraj

Hi Simon,

 

Thanks for your reply. I have not configured any custom triggers on leads. But could you please point me to some documentation around it so that I can check if someone else has done so.

 

Also, please confirm that if the lead is lying in Recycle Bin, then can i create it again or not ?

 

Thanks,

Agraj

 

Mohith Kumar ShrivastavaMohith Kumar Shrivastava

One more reason you may like to look is the parent records associated to that lead is deleted .Like if any of related Id you are trying to use and if its deleted same  error pops up

SRKSRK

it will be grate if you can share the piece of code that you are using to recreate the deleted lead

then it will me more easy to figure out the problem

 

It may be that

AgrajAgraj

Thanks for all the replies.

 

The problem was in my code. It was sending a PATCH request to /services/data/v20.0/sobjects/Lead/[Lead_ID] when Lead_ID was deleted. I tried sending POST to /services/data/v20.0/sobjects/Lead/ with new Lead information and it worked. 

 

Sorry for the inconvenience caused.

This was selected as the best answer
Vinod AdminVinod Admin
Hi could you please help me how to create Lead from thirdparty using REST API. I am new to salesforce please send me the sample code and how can i learn this? please suggest me.