HelpSpot Help Desk Software | HelpSpot Blog | HelpSpot Support

Error Using Request.Create in Web Service Client


#1

I am making an ASP.Net application that is going to interact with our helpspot helpdesk.

I am trying to get the request correct for Request.Create

This is what I have been trying to send in Fiddler HTTP Debugger

POST /helpspot/api/index.php?method=request.create HTTP/1.1
User-Agent: Fiddler
Host: help.domain.com
Content-Type: application/xml
Content-Length: 174

Testing Code - Disregard test@test.com Test User

I am getting the error

<?xml version="1.0" encoding="iso-8859-1"?> 101 Required parameter tNote not supplied 206 Could not create request

I am assuming the formatting of my xml is totally wrong, what format do I need to use?


#2

Hi Mark,

I think you’re a little off on how the API works which is the issue. The API input is all HTTP based. So for a method like request.create you need to pass in tNote, sEmail, etc as HTTP POST parameters.

HelpSpot will then send XML back to you (by default). In the API manual each method lists whether it’s a GET or POST method. GET ones just need to be called via HTTP GET like a browser would, POST needs to call the required URL and then POST the parameter fields.

I’m not familiar with the specifics of how you’d do it in .NET but it’s certainly possible.


#3

I figured it out. If anyone is interesting in VB.Net code for it, this seems to work for me.

Dim uri As New Uri(“http://help.domain.com/api/index.php?method=request.create”)
Dim data As String = "tNote=Testing Code&sEmail=test@test.com"
If uri.Scheme = uri.UriSchemeHttp Then
Dim request As HttpWebRequest = HttpWebRequest.Create(uri)
request.Method = WebRequestMethods.Http.Post
request.ContentLength = data.Length
request.ContentType = "application/x-www-form-urlencoded"
Dim writer As New StreamWriter(request.GetRequestStream)
writer.Write(data)
writer.Close()
Dim oResponse As HttpWebResponse = request.GetResponse()
Dim reader As New StreamReader(oResponse.GetResponseStream())
Dim tmp As String = reader.ReadToEnd()
oResponse.Close()
'Response.Write(tmp)