hey all. Firstly thank you for everyone who has stuck with me while I am correcting my code. I am getting there slowly but surely
Var apiUsername As String = "Username"
Var apiPassword As String = "Password"
Var integrationCode As String = "Key"
Var apiEndpoint As String = "https://webservices16.autotask.net/atservicesrest/V1.0/Companies"
If TextField1.Text = "" Or TextField2.Text = "" Or TextField3.Text = "" Or TextField4.Text = "" Or TextField5.Text = "" Or TextField6.Text = "" Then
MsgBox("Please fill in all fields.")
Return
End If
Var requestBody as New JSONItem
requestBody.Value("companyType") = 1
requestBody.Value("ownerResourceID") = 29682885
requestBody.Value("companyName") = TextField1.Text
requestBody.Value("Phone") = TextField2.Text
requestBody.Value("WebAddress") = TextField3.Text
requestBody.Value("City") = TextField4.Text
requestBody.Value("State") = TextField5.Text
requestBody.Value("CountryID") = TextField6.Text
Var request As New URLConnection
request.SetRequestContent(requestBody.ToString, "application/json")
request.RequestHeader("ApiIntegrationCode") = integrationCode
request.RequestHeader("UserName") = apiUsername
request.RequestHeader("Secret") = apiPassword
'request.send("POST",apiEndpoint)
request.send("POST", apiEndpoint, HandleResponse)
Now that I have corrected the code, it runs (without error) but nothing happens on the other end, ie the company is not created in the CRM .
This is the code I am using and all runs without error.
request.send("POST",apiEndpoint)
But as I said above nothing actually happens in the CRM
However looking at the helpfile it looks like the request send needs 2 strings(?)
MyConnection.Send("GET", "http://127.0.0.1:8080/GetData", outputFile)
But when I do it with this code, It tells me not enough parameters.
request.send("POST", apiEndpoint, HandleResponse)
So not sure if I am supposed to use the HandleResponse in here.
Also I have a method defined, which is using a old deprecated class Xojo.Data
var responseJson As Xojo.Core.Dictionary = Xojo.Data.ParseJSON(responseText)
If responseJson.HasKey(âitemIdâ) Then
MsgBox(âCustomer created successfully!â)
Else
MsgBox("Error: " + responseJson.Value(âmessageâ))
End If
I have a feeling this is where it lies