HelpSpot Help Desk Software | HelpSpot Blog | HelpSpot Support

Attached image files unable to be opened with requests created using API


#1

When I attach an image file (jpeg, bmp, png) to a request that is being created/updated using the API, the file is not
able to be opened in help spot after the request is updated/created. The api calls request.create/request.update are successful. I am using VB.NET to call the web api calls.


#2

Hi,

It sounds like maybe the attachment either isn’t getting stored properly or it’s possibly corrupt?

In your API call can you confirm that you are base 64 encoding the File1_bFileBody? The should also be the file contents and not just the name.


#3

I have confirmed that I am encoding the image file’s body into a base64 string.

I am using the same encoding logic to encode a text file into a base64 string and can successfully create a request through the API.

If I create a request in helpspot and attach an image file to the new request. The image file is viewable from helpspot.

However if I create a request through the API and attach the same image file, the new request (create via the API) attached image file is not viewable, downloadable helpspot.

I am using the .net System.Convert.ToBase64String(…) method to encode the file body.

Below is the function I use to convert a file I am assuming that help spot is using
iso-8859-1 encoding.

Private Shared Function ConvertToBase64String(filebody As Byte()) As String

    Dim iso_8859_1 As Encoding = Encoding.GetEncoding(28591)

    Dim base64String As String
    Encoding.Convert(Encoding.Default, iso_8859_1, filebody)

    base64String = Convert.ToBase64String(filebody)

    Return base64String


End Function

Has anyone else encounter this issue with attached files to a request created via the API?