Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

400 Error #5

Open
braddperry opened this issue May 19, 2017 · 0 comments
Open

400 Error #5

braddperry opened this issue May 19, 2017 · 0 comments

Comments

@braddperry
Copy link

braddperry commented May 19, 2017

Code generates a 400 error. This seems to be due to a missing CURLOPT_POSTFIELDS. However, if you try to post the access token, losing lead, and the merge in crm values as posted fields, you will get 1003 errors.

This will generate a 1003 Error
public function postData(){ $url = $this->host . "/rest/v1/leads/" . $this->id ."/merge.json"; $fields = array( 'access_token' => urlencode($this->getToken()), 'leadIds' => urlencode($this::csvString($this->leadIds)), 'mergeInCRM' => urlencode('true') ); foreach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; } rtrim($fields_string,'&'); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json','Content-Type: application/json')); curl_setopt($ch, CURLOPT_POST, count($fields)); curl_setopt($ch, CURLOPT_POSTFIELDS, $fields_string); curl_getinfo($ch); $response = curl_exec($ch); return $response; }

Sending an empty set of post fields gets rid of the 400 error
public function postData(){ $url = $url = $this->host . "/rest/v1/leads/" . $this->id ."/merge.json?access_token=" . $this->getToken() . "&leadIds=" . $this::csvString($this->leadIds); $fields = array(); foreach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; } rtrim($fields_string,'&'); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json','Content-Type: application/json')); curl_setopt($ch, CURLOPT_POST, count($fields)); curl_setopt($ch, CURLOPT_POSTFIELDS, $fields_string); curl_getinfo($ch); $response = curl_exec($ch); return $response; }

Sending without the mergeInCRM parameter, returns a success. With the mergeInCRM set to true I get a 611 error when merging a contact to a lead. The call will convert the lead to a contact and assign it a new marketo ID. If you run the merge again with the existing contact and the new contact, the contacts are merged in Marketo, but not in Salesforce. It seems the API is just as poor at merging as within the marketo platform natively. It's best just to merge leads/contacts within SF.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant