REST API http POST examples | Community
Skip to main content
January 30, 2015
Solved

REST API http POST examples

  • January 30, 2015
  • 5 replies
  • 4404 views
Hi,

I was playing around with this end point: http://developers.marketo.com/documentation/rest/get-multiple-leads-by-filter-type/ and everything seems to work with the GET request.  However, when I attempted the POST request, I'm getting all sort of errors.  

1) When attempting to make a request with "Content-Type: application/x-www-form-urlencoded", I get this error: [{"code":"612","message":"Invalid Content Type"}].

2) When I change the Content-Type to application/json and pass over this in the request body:
{ "filterType" : "Id" , "filterValues" : "146"}

I would get this error:
[{"code":"1003","message":"Leads not specified"}]

3) When i make a similar request via GET, it would return the lead info for 146 correctly.

What am i missing for the POST request?  Also, where can i find documentations regarding the POST requests? 

thanks for the help.
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 SanfordWhiteman
I wouldn't worry about length limits unless your client imposes one for some reason.  On the server side it's going to end up in the same (dynamic string) variable so it should have the same processing limit.

Also even with a low limit like 8K you're still going to be able to send 100 80-character e-mails -- and 80 characters is a really long e-mail address.

In sum, the method expects query parameters, not an entity-body.

5 replies

SanfordWhiteman
Level 10
January 30, 2015
That endpoint is supposed to be used via GET.  As the documentation states, if you use POST (which presumably you would only do if your client was hard-coded to use POST only), you have to add _method=get override. Obviously it's easier to just use GET.
January 30, 2015
I tried the _method=get override and it didn't work.  Wanted to avoid the GET method since I might need to do look up by email addresses and it'll be batches of 100 emails per call. With possible url length limits in mind, I was hoping it would work via POST.  
SanfordWhiteman
SanfordWhitemanAccepted solution
Level 10
January 30, 2015
I wouldn't worry about length limits unless your client imposes one for some reason.  On the server side it's going to end up in the same (dynamic string) variable so it should have the same processing limit.

Also even with a low limit like 8K you're still going to be able to send 100 80-character e-mails -- and 80 characters is a really long e-mail address.

In sum, the method expects query parameters, not an entity-body.
February 2, 2015
  • _method=GET required when using the HTTP POST method
I think this means your method is POST but parameters are URL likes GET method.
SanfordWhiteman
Level 10
February 2, 2015
I agree and it's strange to require _method override in that situation, since you aren't really overriding anything as you may always pass a query string with a POST.