HTTPSocket yields no result

I am working with the DrChrono API which was working fine until yesterday. It is able to authorize using OAuth2 and I can get an access token and refresh token, however when I go to pull some data, the result is blank and the last error code is 102 - authorization failed.

I looked up the docs for the API and it looks like nothing has changed.

Here is the code I have been using:


Dim http as new HTTPSecureSocket

http.Secure = True
http.SetRequestHeader("Host", "drchrono.com")
http.SetRequestHeader("Content-Type", "application/json")
http.SetRequestHeader("Authorization", "Bearer " + accessToken)
http.ConnectionType = SSLSocket.TLSv12

Dim d As New Dictionary

d.Value("refresh_token") = refreshToken
d.Value("grant_type") = "refresh_token"
d.Value("redirect_uri") = "http://localhost:3017/"
d.Value("client_id") = client_id   
d.Value("client_secret") = client_secret  

http.SetFormData(d)

// This service simply returns the post data as the result
Dim result as String 
result = http.Post("https://drchrono.com/o/token/",30) // Synchronous

result now is completely blank. Not even an error message.

I’m using MacOS 15.15.1 and Xojo 2022r4.1

Any help would be greatly appreciated.

With 2022r4.1 I would recommend changing to URLConnection. It should be mostly straightforward, but you will need GitHub - einhugur/MultipartFormDataContent: MultipartFormDataContent class for Xojo to replace SetFormData.

2 Likes

Thanks. I will look into that.

That was the solution - using URLConnection. I did not need the MultipartFormDataContent class however. I was able to use a URL-encoded string to send the data.

Thanks for your help.

Can you please mark @Tim_Parnell solution as such? Thank you :blush: