SOLVED

Re: REST API http POST examples

Go to solution
Anonymous
Not applicable

REST API http POST examples

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.
Tags (1)
1 ACCEPTED SOLUTION

Accepted Solutions
SanfordWhiteman
Level 10 - Community Moderator

Re: REST API http POST examples

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.

View solution in original post

5 REPLIES 5
SanfordWhiteman
Level 10 - Community Moderator

Re: REST API http POST examples

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.
Anonymous
Not applicable

Re: REST API http POST examples

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
Level 10 - Community Moderator

Re: REST API http POST examples

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.
Anonymous
Not applicable

Re: REST API http POST examples

  • _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 - Community Moderator

Re: REST API http POST examples

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.