HelpSpot Help Desk Software | HelpSpot Blog | HelpSpot Support

Api Attachment Call


#1

Hello,

I’m having issues when attaching images or other non-text file documents through the api. Is there a secret that I’m missing when it comes to different files types? I’m can attach text files just fine, and see them on the website and via my own api call.

When I attach a jpg or png it comes up as a blank image when I open up via the ui or api. I’m able to attach the same image file within the website ui and it works fine accessing it from the website but not the api.

Any suggestions would be great.

Thanks in advance.


#2

Update :

I’ve added a preview thumbnail to my submit form and I’m able to see the image just fine using the same base64 encoding call. And when I try to open the attachment via the website I see this. (see images)

I have also tested using quotes around the base64 data, used the entire string instead of just the body from the file reader, encoded the string body with URI, did the same to the whole request which in turn broke the call, verified that the the files I’m attaching fit under the normal file types allowed via these type of calls.

Any suggestions would be great, thanks in advance.

-dbass


#3

Follow up question to hopefully shed some more light on the issue. When building the create or update string to send, I put the collection of File#_bFileBody at the end of the entire string. I don’t believe so, since text is working, but again just pointing things out to see if I can clear things up and make it more clear.

As stated in the last message I tried to encode uri when passing the bFileBody which seemed to not have helped, but should I encode the entire thing or more specifically each secion of the attachment process.

I was also wondering if there is a limit of characters to send through an url considering that the File#bFileBody can become pretty large.

Below is what I’m currently sending, and is the same image as the previous example (I have shortened the FileBody).

If anyone could give some insight of why they think its not working that would be great, thanks in advance!

&File1_sFilename=sample-graphic%20(1).jpg&File1_sFileMimeType=image/jpeg&File1_bFileBody=data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEASABIAAD/2wBDAAICAgICAgICAgICAgICAwMDAgIDAwQDAwMDAwQFBAQEBAQEBQUGBgcGBgUHBwgIBwcKCgoKCgoKCgoKCgoKCgr/2wBDAQMDAwQDBAcFBQcLCQcJCwwLCwsLDAwKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgr/wAARCAGQAiYDAREAAhEBAxEB/8QAHgABAAMAAgMBAQAAAAAAAAAAAAcICQUGAgMEAQr/xABQEAABBAECAwUDBwcFDAsAAAAAAQIDBAUGEQcSIQgTFDFBCSJhFRYjMkJRgTM4UnFydrQkNnWRoRcYU1RigoOTorGz0yUmNDdDRGRztcHh/8QAHAEBAAEFAQEAAA…