HelpSpot Help Desk Software | HelpSpot Blog | HelpSpot Support

Help - files added to request using API private.request.create are missing after request creation


#1

I am creating requests successfully however files that I have sent as part of the parameters of the create request method are not being added to the request in helpspot.

The help spot request is being created successfully (with an xRequest being returned).

I am not sure what is

I am using the api private.request.create and passing a file attachment to the request
using these parameters
File1_sFilename (# is the file number starting at 1)
File1_sFileMimeType
File1_bFileBody (Base64 Encoded File Body)

I am using ASP.NET, VB, to create the request via the helpspot web api

The is an example of what i am passing to the method
https://myhelpspot/api/index.php?method=private.request.create&username=someuser&password=somepassword

Posted Data:
tNote=Note Body&
xCategory=6&
fNoteType=1&
sTitle=Test Message&
fOpen=1&
xStatus=3&
sUserId=&
sFirstName=First&
sLastName=Last&
sEmail=testemail@mydomain.com&
fOpenedVia=6&
email_from=info@mydomain.com&
File1_sFilename=C:\Users\myid\Documents\Helpspot integration\HelpSpotTestPages\TestAttachment.txt&
File1_sFileMineType=text/plain&
File1_bFileBody=File Body…(in Base64 using Convert.ToBase64String(…) )

Below is the code I have written in VB to send the request and retrieve the response

Dim url = String.Format(“https://myhelpspot/api/index.php?method=private.request.create&username={0}&password={1}”, USERID, PASSWORD)

    'Populate Request with data
    Dim hsRequestString As String = HelpSpotRequest.SerializeRequestToString(hsRequest)

    Dim webRequest As HttpWebRequest = HttpWebRequest.Create(New Uri(url))
    webRequest.Method = WebRequestMethods.Http.Post

    webRequest.ContentType = "application/x-www-form-urlencoded"
    webRequest.ContentLength = hsRequestString.Length

    Dim requestWriter As New StreamWriter(webRequest.GetRequestStream())
    requestWriter.Write(hsRequestString)
    requestWriter.Close()

    Dim xml As String

    Using webResponse = webRequest.GetResponse()
        Dim r As StreamReader = New StreamReader(webResponse.GetResponseStream())
        xml = r.ReadToEnd()
    End Using

    Dim xdoc As New XDocument
    xdoc = XDocument.Parse(xml)

    Dim xResponse As String = (From r In xdoc.<request>
                               Select r.<xRequest>.Value).Single()

    Return xResponse

#2

One minor issue is you have a spelling mistake in what you posted:

File1_sFileMineType

Should be:

File1_sFileMimeType

Mine vs Mime

That could be related to it not attaching because that is a field it’s looking for, and in this case not finding it.


#3

Thanks, After I changed the “n” to an “m” it is a now creating requests in helpspot with attachments. :smiley:


#4

Excellent!

Those are always the tricky ones to spot and find. :smile: