Getting globbing nested brace error at column 189 with curl PUT request to Sheets API

I’m having trouble updating data in a Google Spreadsheet using the Sheets API v4. When I try to send a PUT request with curl, I keep getting an error.

Here’s the curl command I’m using:

curl -v \
-H 'Authorization: Bearer ya29.abc123xyz789-sample-token-here-def456ghi789' \
-X PUT \
https://sheets.googleapis.com/v4/spreadsheets/1sampleSpreadsheetId123/values/Data\!B2:E6\?valueInputOption\='RAW' \
-d '{"range": "Data!B2:E6","majorDimension": "ROWS","values": [["Product", "Price", "Available", "Delivery"]]'

But when I execute this command, I get this error message:

curl: (3) [globbing] nested brace in column 189

I’m not sure what’s causing this globbing issue with the braces. Has anyone encountered this problem before? What am I missing in my curl syntax?

try escaping the braces with backslashes: \{ and \}. your json’s also missing a closing bracket and brace at the end - that’s probably causing issues too.

I encountered a similar issue with the Google Sheets API when using curl. It seems that the nested braces in your JSON payload are causing confusion for curl as it interprets them as special characters. A straightforward workaround is to place your JSON in a separate file, for example, data.json, and use the command curl --data @data.json instead of using -d inline. This way, curl reads the data directly from the file without getting tangled in globbing issues. Additionally, ensure that your JSON structure is complete with the necessary closing braces and brackets.

The globbing error occurs because curl interprets curly braces as special characters for URL globbing. In your JSON data, those braces are being misinterpreted instead of being treated as literal text. I’ve encountered this issue before when working with APIs that require a JSON payload. To fix this, try adding the -g flag right after curl -v to disable globbing, or alternatively, wrap the entire JSON payload in single quotes while ensuring there are no unescaped single quotes within. Lastly, verify that your JSON structure is correctly closed; it appears you are missing the closing brace and bracket in your data payload.