"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 20, 2014
@Jose, I am glad you were able to get this resolved! Thanks for closing the loop. 
December 20, 2014
Yes! That worked.  

So:
  • Murtza's first reply was the right one for my original question.
  • The rest of the thread helped me fix a separate issue we had when submitting the forms to Marketo: we were missing the _mkt_trk hidden field, so the cookie value was not being stored with the lead data.
Thanks Murtza for your help through all this process.
Jose
December 20, 2014
I am not sure. It is possible. Let me know if following steps in that blog post solve the issue. 
December 20, 2014
I am now going to make sure our form submission code comply with the specs in this post - by Murtza Manzur himself -  and try again. I will post here the results.
December 19, 2014
Wait - just thought of something.
All the forms I ever filled are hosted on our website, and from the webserver we do a HTTP POST to Marketo.
(that's why we need to implement the auto-fill on our side)

Maybe the cookie on our website domain (xxxxxxxxx.com) is never "making" it into the Marketo databases...
December 19, 2014
I just filled out a form with email and other fields, and when I go to the Lead info (Activity Log) I can see the values have been changed as entered in the form. However, I still get an empty results collection using the _mkto_trk cookie on that domain

May it be a permissions issue? I've created the API role, user and service as described here http://developers.marketo.com/blog/quick-start-guide-for-marketo-rest-api/ 

Thanks
Jose 
December 19, 2014
I would make sure you are querying for a known lead in Marketo (a lead that is associated with an email address). Fill out a form and include an email field. Then query with that cookie value. 

I am not aware of any way to query in the UI with cookie value. I think cookie value is only exposed through API.
December 19, 2014

Hmm, unfortunately it made no difference :(

Do I have any way of checking, with the Marketo Portal, if that cookie has some information attached?

Thanks!
jose

December 19, 2014
You are close! I think you are just missing one thing. Add cookies to the list of fields requested. See change below to your request. 

https://220-bkt-314.mktorest.com/rest/v1/leads.json?access_token=742e72b9-176b-4ae2-9754-63e174cab277%3asj&filterType=cookie&filterValues=id:220-BKT-314%26token:_mch-keynote.com-1417097326740-26128&fields=cookies

Let me know if that works?
December 19, 2014
Hi Murtza
thanks again for your help

By rewriting my code from scratch, I do no longer get the "invalid cookie" error.
Unfortunately, the results collection comes empty 
{"requestId":"a095#14a63cd8d05","result":[],"success":true}
even when I have filled several Marketo forms on the same laptop+browser.

This is the URL I am requesting (HTTP GET from the web server running on IIS):

https://220-bkt-314.mktorest.com/rest/v1/leads.json?access_token=742e72b9-176b-4ae2-9754-63e174cab277%3asj&filterType=cookie&filterValues=id:220-BKT-314%26token:_mch-keynote.com-1417097326740-26128&fields=id,email

Any ideas of what I may be doing wrong?
Thanks again.
Jose