1 Reply Latest reply on Oct 23, 2018 2:05 PM by Sanford Whiteman

    Associate Web Activity api - response 400 bad request from marketo

    Sagar Pawar

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


      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);




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



        [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.

        • Re: Associate Web Activity api - response 400 bad request from marketo
          Sanford Whiteman

          First, realize that the language you use is immaterial to the problem. You should know exactly what you're putting on the wire (the URL, headers, and JSON body) and that falls outside of PHP. A fundamental part of debugging is separating your code from the HTTP traffic itself.


          Second, if posting code please always highlight it using the Advanced Editor's syntax highlighter.





          Third, if it's really true that "the code works fine outside [y]our company network" this is a job for your IT crew, not for the Community, since they likely have you going through an HTTP proxy.