"Invalid cookie value" when calling REST API leads | Community
Skip to main content
December 12, 2014
Solved

"Invalid cookie value" when calling REST API leads

  • December 12, 2014
  • 14 replies
  • 4109 views
I'm trying to get the lead information for the current user in a website, using this REST API: Get Multiple Leads By Filter Type

I have the right authentication token ( I am able to call other entries, i.e. /lead/{id}.json ) but whenever I call the "leads" resource with filterType=cookie&filterValues=xxxxxxxxxxxxxx I get a JSON error response with this value in the message property:
Invalid cookie value 'id:561-HYG-937&token:_mch-marketo.com-1415884534947-30230'
I have encoded the '&' inside the cookie value as %26, and it is reaching the API correctly.  The value stated in the error message matches exactly the value of my _mkto_trk cookie on the 'marketo.com' domain.

Any clue on what I may be doing wrong?
Thanks in advance
Jose
This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by
For future viewers of this thread, I also updated this developer blog post with the example:
http://developers.marketo.com/blog/get-a-visitors-cookie-id-and-then-query-associated-lead-data/

14 replies

December 17, 2014
I'm happy to help debug. Can you post the request url and JSON body that your code generates? 
December 17, 2014
Thanks Murtza for your prompt response. I'm following just the same steps and cannot get it to work, but I may be doing something wrong.  Will re-trace each step again.

Thanks
Jose 
Accepted solution
December 12, 2014
For future viewers of this thread, I also updated this developer blog post with the example:
http://developers.marketo.com/blog/get-a-visitors-cookie-id-and-then-query-associated-lead-data/
December 12, 2014
I am not sure where the error is if you are changing the & to %26.  I justed tested the API, and here is a working code sample in Ruby:

===
Code Sample
===

require 'rest_client'
require 'json'

#Build request URL
#Replace AAA-BBB-CCC with your Marketo instance
marketo_instance = "https://AAA-BBB-CCC.mktorest.com"
endpoint = "/rest/v1/leads.json"
#Replace with your access token
auth_token =  "?access_token=" + "cdf27eff-aca0-48cf-a1ac-576ffec65a84:ab"
#Replace with filter type and values
filter_type_and_values = "&filterType=cookie&filterValues=id:AAA-BBB-CCC%26token:_mch-marketo.com-1418418733122-51548&fields=cookies,email"
request_url = marketo_instance + endpoint + auth_token + filter_type_and_values

#Make request
response = RestClient.get request_url

#Returns Marketo API response
puts response

===
Response
===
{"requestId":"aa00#14a405aa786","result":[{"id":583,"email":"testaccount@gmail.com","cookies":"_mch-marketo.com-1418418733122-51548"}],"success":true}