Blockquote
That makes no sense. Looks like you just don’t know what you’re doing, not learning. First learn, then do it, from there you see “mistakes” and have few founded doubts, and won’t say “I have no clue what I’m doing”. Where did you get this code that you have no clue how it works?
We all learn in different ways I am learning by making the mistakes (which it clearly seems like I have done) .
I wrote most of the code myself and found some examples on the internet of how to do the rest.
This is how I learn, write code that I think is correct, and then ask for help from peers. Isnt that what this forum is all about… helping each other out.
I am just trying to get some help and would appreciate people not being rude. if that’s too much to ask
Well… I don’t see myself being rude. Just as you I’m having questions on how you are leaning or not, and if there’s a better way to do it.
Not saying that’s your case, but in times of ChatGPT, sometimes I’m seeing “learners” using codes like yours, using incomplete, not functional, old syntax code, and they just know what they are doing either, that’s why I asked.
Currently it is difficult to separate genuine learning attempts, from lazy people trying to cheat. As it is not your case, simply do not get offended and just keep going.
Interesting. Never even crossed my mind that ChatGPT could help. Did not think it would know about XOJO code.
All good my friend I am just trying to understand how things work and why my code is not working… I often find it easier to examine code from someone else and try to figure out what is happening from there, rather than do it all myself because then I get into these problems where I don’t really know if its working or not.
Yes I think that’s the thing here is I know enough to get started but not enough to be able to diagnose further and I find it easier sometimes to learn from how others do it rather then spending hours fumbling around and getting frustrated with it
Just keep going. To update your code you should not use Text, use URConnection instead of HTTPSocket, no deprecated Xojo.* functions, I would opt for using JSONItem for your JSON/Dictionary needs.
Both Text and Xojo.Data.GenerateJSON are deprecated. Unfortunately, you have chosen an old example to start from. Actually, anything in the old Xojo.* namespace should be avoided.
Your example is using Dictionary instead of the deprecated Xojo.Core.Dictionary, which is why you’re getting the exception. Dictionary is not compatible with Xojo.Data.GenerateJSON.
Some years ago, Xojo decided to namespace everything under Xojo.*. They also introduced the Text data type. It was largely considered a failed experiment. They rewrote String to incorporate the best of Text and redid the Xojo.* functions under other names. Then they deprecated all of that. Unfortunately, there’s still a lot of code floating about the internet that uses them.
The documentation site documentation.xojo.com is a good resource to investigate your questions, as are the many example projects contained in your xojo install.
And at any point in time, how will these AI jobbies know the difference between useful code and code full of deprecated constructs, if the Internet is “full of old code” ??
Ok I have made some changes to the code. I am now using Var instead of DIm and String instead of Text .
Also Using URLConnection instead of HTTPSocket
Some things are still not working correctly
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"
Var request As New URLConnection
request.SetRequestContent("", "application/json")
request.RequestHeader("ApiIntegrationCode", integrationCode)
request.RequestHeader("UserName", apiUsername)
request.RequestHeader("Secret", apiPassword)
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") = 4
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 requestBodyJson As String = Xojo.Data.GenerateJSON(requestBody)
request.SetRequestContent(requestBodyJson, "application/json")
request.Post(apiEndpoint, AddressOf HandleResponse)
```Not sure if I am using the RequestHeader Method correctly here, According to the Docs its valid so not sure if I am doing it wrong again.
ALso There is no member for POST in URLConnection, what can I use instead of that I tried Send and it did not work

Am I going about this the correct way
I have mostly made it up with my very limited knowledge some of it was copied from an old VB code I had and then I made it more XOJOified so probably all completely wrong for what I am trying to do.
Basically, all I am trying to do is to take information entered in Text boxes and create a company via a web services API in my CRM.
Var apiUsername As String = "Username"
Var apiPassword As String = "PAssword"
Var integrationCode As String = "integrationCode"
Var apiEndpoint As String = "https://webservices16.autotask.net/atservicesrest/V1.0/Companies"
Var request As New URLConnection
request.SetRequestContent("", "application/json")
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
request.SetRequestContent(requestBody, "application/json")
request.send("POST",apiEndpoint)