Image upload via API | Community
Skip to main content
Shruti_Khullar
Level 2
September 26, 2018
Question

Image upload via API

  • September 26, 2018
  • 1 reply
  • 6023 views

Hello,

There is a requirement to upload an image to Marketo via API.

I am facing the below issue:

Could anyone share the code snippet or the process on how to proceed with it.

Thanks in advance!

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

1 reply

SanfordWhiteman
Level 10
September 26, 2018

Your payload does not contain any image data. That's plain to see.

Please see my answer at Creating File: File is mandatory for an example of the correct MIME payload. The same MIME rules apply with binary images as with text; you can't just change the format and try to include a remote src! You need to make a POST containing the file, not a reference to a remote file.

Also, screenshots are a bad idea here unless you show all your control characters, since extra/missing line breaks and extra spaces are prime causes of MIME formatting errors.

September 30, 2018

Hi Sanford,

I have followed the below steps:

- Used endpoint : /rest/asset/v1/files.json

- Used header as Content-Type: multipart/form-data.

- Used body text as you suggested in this Creating File: File is mandatory

   

   

I'm using Rest API google extension and got below response:

Please let me know where the error in code so i can correct it. Actually, we want to import image files(JPG, PNG and GIF) into the marketo, If you know please help us on that .

Thanks in advance!

SanfordWhiteman
Level 10
September 30, 2018

You can't just randomly insert line breaks, as linebreaks (CRLF) are part of the essential structure of MIME. I thought I was crystal-clear about this when I wrote:

Also, screenshots are a bad idea here unless you show all your control characters, since extra/missing line breaks and extra spaces are prime causes of MIME formatting errors.

Your screenshot also shows some random Velocity #set() syntax outside the MIME boundaries. I have no idea why that is in there. This task has no relation to Velocity and the payload will break from that alone.

Also, I don't understand how you can say you used my payload from the other thread when yours looks totally different.  Do you really not see the giant differences: the extra line breaks and the extra Velocity code?

While assembling a File API payload is not difficult, it requires close attention to detail. If you're not comfortable with the precision required to get this working, you'll need to hire a professional developer.