0

I wrote my code so that every call to the SalesForce API is logged. If the user uses our iPhone app, their message is sent to our server, and then our server does some Natural Language Processing to figure out what the user really meant to say, and then we update the user's info in SalesForce. If a user writes:

"Amara Veri of Tata Enterprises has agreed to buy $100000 of scrap iron. We close on September 29."

Then we extract some of that data and send it to SalesForce, filling in the correct fields.

Everytime the API is called, I have my code log the instance_url and the service url that we are targeting. In my logs, I see this message:

the base url:  https://na15.salesforce.com

the full url:  https://na15.salesforce.com/services/data/v34.0/sobjects/Opportunity/

This shows up once. And yet, when I log into the account where I am testing some of this, I see that 2 new Opportunities were created, both with the same name: Amara Veri of Tata Enterprises.

Is there ever a case where SalesForce gets one API call but reads it as 2?

1 Answer 1

1

Definitely it is hard to tell what is happening as you are having integrated systems. What Salesforce recommends is making sure your operations are idempotent, which means if multiple messages are sent to Salesforce, Salesforce will understand that the non original message is redundant. This can be achieved by having unique Id sent from your system with each message. Salesforce checks this Id and only process messages with unique Ids.

4
  • Where can I find information about this "unique Id sent from your system with each message"? How does Salesforce support that? Commented Sep 15, 2015 at 14:53
  • Are you using standard rest or have your own handler? For standard, you can construct an external Id and use it to upsert records instead of just inserting. This can be any generated token you add to op data. If you are using your handler you need to just check if opportunity exist with same generated token and either ignore or update. Let me know if you have questions. Commented Sep 15, 2015 at 20:24
  • I rebuilt the app and the problem went away. I have no idea what caused it. Commented Sep 17, 2015 at 9:10
  • Great news ... Glad you got it to work Commented Sep 17, 2015 at 12:33

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .