Marketo REST API gives invalid HTTP response when request URI is too long

Anonymous
Not applicable

Marketo REST API gives invalid HTTP response when request URI is too long

The Marketo REST API does not return a valid HTTP response in JSON format when the request URI exceed a particular limit. Due to this we are unable to handle this scenario where for Get Multiple Leads by List ID api, the user has provided a large list of fields leading to a long request uri.

Is this a bug in the Marketo REST API?
Tags (1)
3 REPLIES 3
Anonymous
Not applicable

Re: Marketo REST API gives invalid HTTP response when request URI is too long

On further investigation I found then whenever there is a 414 - Request URI is too long error, Marketo does not return any headers in the response which makes it difficult to handle such responses by the client.
 
Anonymous
Not applicable

Re: Marketo REST API gives invalid HTTP response when request URI is too long

The workaround here is to use the POST method instead of GET. This should allow you to get around request limitations with GET because of the long URL. 

If using the POST method, you will need to pass the parameter "_method=GET" with your request.
Anonymous
Not applicable

Re: Marketo REST API gives invalid HTTP response when request URI is too long

I tried using the POST method with "_method=GET". But the API does not recognize the fields parameter that I pass in the post body and only returns the default fields. Could you please give me an example code that I can refer for setting the fields parameter in the POST body.

Here is what I tried:
fields=company,site

{
  "fields": "company,site"
}
 
{
  "fields": [
    "company",
    "site"
  ]
}