Write to google sheets with URLconnection

I’m having trouble writing to a google sheet using URL connection like this:

Window1.URLConnection1.SetRequestContent(json.Emit(),  "application/json")
Window1.URLConnection1.Send("POST", postURL)

The result is nothing appears in the google sheet.

The postURL is this:

8:17:06 AM : postURL = https://sheets.googleapis.com/v4/spreadsheets/15E_SLkRNh2Z82iTzbylrXgEB9848bIDF2WJzM8c9pHk/values/FV 1!B27:G27?valueInputOption=USER_ENTERED

The json is this:

8:17:08 AM : json.Emit() = {
  "range": "FV 1!B27:G27",
  "majorDimension": "ROWS",
  "values": [

I’m following the google example that uses PUT and I’ve tried that and POST with no luck :

I’m certain that access authorization has been successful because previous to attempting the write the code reads the google sheet and successfully determines the range to receive the data.

your code doesn’t show authentication?
Any error returned? Output from that request? Maybe some JSON with error details?

Did you try with CURLSMBS class instead?

How are you handling the access and refresh tokens? Are you including the Bearer token in the Authorization header with every request?

What content is received from the server in the URLConnection.ContentReceived event?

Authentication is reported to have been successful:

2:26:07 PM : DMA_5000_M_Controler Launched
                  fileType = 1
                  jsonToken = 1//0dEU5z0m6AbKsCgYIARAAGA0SNwF-L9IrkBJYUxcoPvcMJSwBHKaXPQVJwW7IJQxRIKEuWNybI6WcaDsEUMqV3wxL8nJgF3HWkY0
                  Unlocked using purchased unlock code.
2:26:08 PM : OAuth2 authorization granted!
                  OAuth2 token is {
  "access_token": "ya29.a0AfH6SMBTr4_34GUCbohwNAw6fioc98UVAi4efRFD4SRyDPwjpK3SPQL2FBSasJGxa-RS9_7MvXrCauLRlhPQb-VKh5VD7sxWazmbnOqMXPD1AXEAfJjul-HG57AwcuaJZOd99Fg-AnRtYwAzDTl7_h4bhBQ8EVRvFH4D",
  "expires_in": 3599,
  "scope": "https://www.googleapis.com/auth/spreadsheets",
  "token_type": "Bearer"
                  theAccess token is ya29.a0AfH6SMBTr4_34GUCbohwNAw6fioc98UVAi4efRFD4SRyDPwjpK3SPQL2FBSasJGxa-RS9_7MvXrCauLRlhPQb-VKh5VD7sxWazmbnOqMXPD1AXEAfJjul-HG57AwcuaJZOd99Fg-AnRtYwAzDTl7_h4bhBQ8EVRvFH4D

The URLConnection.ContentReceived event is never triggered, that is:

System.DebugLog("Content received = " + content)

returns nothing.

I’ll make of note to give CURLSMBS a try if this interaction with google sheets can’t be done with the built in Xojo tools.

FYI, this code is running on a raspberrypi running linux, so I did try applying linux style (\n) line endings in the json, but that didn’t help

// Use UNIX line endings
json.EmitCrLf = False

This thread can be closed because Chilkat solved the problem running their libraries on rasperrypi, so I’ll go that route.