I am new to both making API calls and coding in Apex and feel way over my head.

How can I make a call to the Marketo REST API through Salesforce? Is this possible through Apex?

For example, hypothetically, say I didn't want to use the automatic sync of Marketo and Salesforce for some reason. Would it be possible to use Apex to push a lead to Marketo manually using something similar to this:

  1. When a new lead is created, trigger Apex class "syncLead"

  2. syncLead requests token and logs in to Marketo from Salesforce, so I can use the Marketo API

  3. syncLead makes an SOQL to Salesforce, and stores data for Lead01 as, for example, Map m

  4. syncLead makes POST to create a new lead in Marketo using the information from Map m

Otherwise, is there another way to do this? Perhaps by linking to an external database through Salesforce?

  • yep - this should work except for a couple of issues - (1) the trigger needs to be bulkified to handle many leads in one transaction - this means that you need to work around governor issues on callouts; and 2) the trigger implicitly has the Lead data in trigger.new so no SOQL is required in step 3 – cropredy Aug 12 '15 at 22:26

As per your above requirements:

  • I think you should go for workflow rules - Outbound Message service of Salesforce. Send the outbound message to Marketo when ever new record is created for Lead Object or use a small php/java web application in between when ever outbound message is received to the mentioned integration endpoint in turn it create the new record in Marketo & send acknowledgement to Salesforce too. There is a Integration & Data sync between Marketo and Salesforce
  • Your own solution is also good.
| improve this answer | |
  • your link goes to the Marketo home page; do you have a more specific link? – cropredy Aug 14 '15 at 1:26

Not the answer you're looking for? Browse other questions tagged or ask your own question.