Good Morning, I'm looking for a way to update the dropdown values in a column in my Smartsheet. Going off the Smartsheet API 2.0, I managed to come up with the following code to use with curl, but I'm getting the following error when running it in CMD.
Here is the code I'm using:
curl https://api.smartsheet.com/2.0/sheets/7654838910642052/columns/4 -H "Authorization: Bearer 6cn0otb4tdjueqzuflgnkzff17" -X PUT -d '{"title":"Weekend Date","index":4, "type" : "PICKLIST", "options" :["31-OCT-2015"]}' -k
The error message I get from CMD, is as follows:
C:\New>curl https://api.smartsheet.com/2.0/sheets/7654838910642052/columns/4 -H "Authorization: Bearer 5cn0otb4tdjueqzuflgnkzff17" -X PUT -d '{"title"
:"Weekend Date","index":4, "type" : "PICKLIST", "options" :["31-OCT-2015"]}' -k
{"errorCode":1124,"message":"Invalid Content-Type header. Media type not supported."}curl: (6) Could not resolve host: type; Host not found
¶hA▓╔ôÒ±$═»ù0♠~¡lk§☺▄ÜQK¡^ Õf ƒîa♀ÛæçÂ"õ8Ê╝±↕åÊJcurl: (6) Could not resolve host: PICKLIST,; Host not found
curl: (6) Could not resolve host: options; Host not found
curl: (3) [globbing] error: bad range specification after pos 3
Would appreciate any help I can get!!! This error is really annoying, and I have spent a good few hours trying to fix it.
** Note that I have changed the access token for security reasons, but the token I am using is definitely valid **
As Joseph suggested in his answer, you'll certainly want to verify that the value you're specifying for {columnId} in the URL is valid. However, the error you're getting is likely unrelated to that issue.
What's likely happening is that cURL is automatically setting the Content-Type header for you to the value "application/x-www-form-urlcoded" -- which is not a valid content type for this request to Smartsheet. You can resolve this error by simply setting the Content-Type header yourself in the request (i.e., add this: -H "Content-Type: application/json"
to the request).
For example, my request to update the picklist options for a column such that the only option is "31-OCT-2015" looks like this:
curl https://api.smartsheet.com/2.0/sheets/{sheetId}/columns/{columnId} -H "Authorization: Bearer YOUR_TOKEN" -H "Content-Type: application/json" -X PUT -d "{\"type\":\"PICKLIST\", \"options\":[\"31-OCT-2015\"]}" -k
Note that to update picklist options, the only attributes I need to set in the JSON are type
and options
. Also note that I used (escaped) double quotes in the JSON instead of single quotes -- you may or may not need to do this (depending on your platform).