Create File REST API

Anonymous
Not applicable

Create File REST API

Hello

I was just curious if anyone has used Marketo REST API to Create a File? It's under - Create a File » Marketo Developers.

I have gone through the examples and trying to upload an Image file (PNG) via this API using Python (2.7). But no success! I am getting this error message -

u'errors': [{u'message': u'name is mandatory', u'code': u'701'}, {u'message': u'file is mandatory', u'code': u'701'}

The Java example uses boundary but I am trying to implement this in Python without any boundary. Hope that makes sense!

The issue is somehow I am the "name" and "file" is not getting passed through even though I am sending them over. Looked up online and found useful hints but somehow nothing has worked so far .

Any idea?

On the side note - can someone confirm if the PHP example mentioned on that API page works?

Tags (3)
2 REPLIES 2
SanfordWhiteman
Level 10 - Community Moderator

Re: Create File REST API

multipart/form-data always has a boundary.  That's how the MIME parts are separated.

Kenny_Elkington
Marketo Employee

Re: Create File REST API

Sanford is correct, the boundary is part of the multipart/form-data content type.  The RFC is here: http://www.ietf.org/rfc/rfc2388.txt  ​ I highly recommend finding a library or framework that can handle the encoding for you as the standard is very frustrating to work with.

For the PHP, yes it works, though CURLFile is PHP 5.5=<.  You need to use the old @file notation for older versions when using libcurl.