AnsweredAssumed Answered

Associate Web Activity api - response 400 bad request from marketo

Question asked by aa039e9328ea16a1cd682ddeaffa7566de35836e on Oct 23, 2018
Latest reply on Oct 23, 2018 by Sanford Whiteman

To associate web activity we are generating access_token and lead id using Marketo rest API and using below code to associate web activity.

<?php

echo $url = 'https://xxxxxx.mktorest.com/rest/v1/leads/xxxxx/associate.json?access_token=xxxxx-xxxx-xxxxxxxx-xx:xx&cookie==_mkto_trk%3Did%xxxxx-xxxx-063%26token%3A_mch-infostor.com-1540199961345-48678';

$ch = curl_init($url);

curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

curl_setopt($ch, CURLOPT_POST, 1);

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json', 'Content-Type: application/json'));

curl_setopt($ch, CURLINFO_HEADER_OUT, true);

$response = curl_exec($ch);

$information = curl_getinfo($ch);

var_dump($response);

var_dump($information);

?>

But we are getting 400 bad request as response from Marketo . Below is curl header information.

Array

(

  [url] => https://xxxxxx.mktorest.com/rest/v1/leads/xxxxx/associate.json?access_token=xxxxx-xxxx-xxxxxxxx-xx:xx&cookie==_mkto_trk%…

  [content_type] => text/html

  [http_code] => 400

  [header_size] => 145

  [request_size] => 323

  [filetime] => -1

  [ssl_verify_result] => 19

  [redirect_count] => 0

  [total_time] => 1.638

  [namelookup_time] => 0

  [connect_time] => 0.015

  [pretransfer_time] => 1.248

  [size_upload] => 0

  [size_download] => 166

  [speed_download] => 101

  [speed_upload] => 0

  [download_content_length] => 166

  [upload_content_length] => -1

  [starttransfer_time] => 1.638

  [redirect_time] => 0

  [certinfo] => Array

  (

  )

 

  [request_header] => POST /rest/v1/leads/xxxxx/associate.json?access_token=xxxxx-xxxx-xxxxxxxx-xx:xx&cookie==_mkto_trk%3Did%xxxxx-xxxx-063%26token%3A_mch-infostor.com-1540199961345-486785-48678 HTTP/1.1

Host: xxxxx.mktorest.com

accept: application/json

Content-Type: application/json

Content-Length: -1

Expect: 100-continue

)

 

But this code works fine outside our company network. Please let us know are we missing anything in above code.

Outcomes