Sample cURL throwing errors
Hello All,
I am looking to use cURL for some basic API updates to my sheets. I have used it successfully to pull down data for columns/summary sections, but when I try using the sample cURL to add a field (after updating the cURL for my sheetID and APIkey), it throws errors. Any idea why this might be happening. Wondering also what access I need as I am an admin (business plan) to the sheet and am able to use cURL to pull data. Here is the string I am using:
https://api.smartsheet.com/2.0/sheets/1234567890/columns \-H "Authorization: Bearer MYSMARTAPIKEY" \-H "Content-Type: application/json" \-X POS
T \-d '[{"index":0,"locked":"false","lockedForUser":"false","title":"PM","type":"TEXT_NUMBER"}]'
{
"errorCode" : 1004,
"message" : "You are not authorized to perform this action.",
"refId" : "s86osu"
}curl: (3) URL using bad/illegal format or missing URL
curl: (3) URL using bad/illegal format or missing URL
curl: (3) URL using bad/illegal format or missing URL
curl: (3) URL using bad/illegal format or missing URL
curl: (3) URL using bad/illegal format or missing URL
curl: (6) Could not resolve host: POST
curl: (3) URL using bad/illegal format or missing URL
curl: (3) bad range specification in URL position 3:
'[{index:0,locked:false,lockedForUser:false,title:PM,type:TEXT_NUMBER}]'
^
Answers
-
Just to test in case it's a permission restriction on the sheet, can you try doing the same action manually in the Smartsheet UI?
I would also test updating a different sheet, perhaps one that you own, to see if it's a sheet-specific issue.
The fact that you can read data means that your bearer token is correct, however it sounds like you may only have Editor access to that sheet or that the data you're updating may be a column that is unable to be changed in that way (e.g. a column formula or one that's used with dependencies).
Cheers,
Genevieve
Need more help? 👀 | Help and Learning Center
こんにちは (Konnichiwa), Hallo, Hola, Bonjour, Olá, Ciao! 👋 | Global Discussions
-
Thanks for the response. Not sure what exactly was the issue. I moved to using PowerShell and everything works as expected. The results I was showing came from a Website utility. May have been something on their end.
My last major hurdle is getting quoted parts of a formula to get imported. When exporting, quotes in the formula come like this =if(X=1, \one\, \not one\). When I use the same syntax to get that data to an update or add command, it fails. I tried \" and also double-quotes. Any suggestions on what to try next?
-
I don't work with Powershell but I would expect the formula syntax to be the following:
"=IF(X = 1, \"one\", \"not one\")"
Let me know if that worked!
Cheers,
Genevieve
Need more help? 👀 | Help and Learning Center
こんにちは (Konnichiwa), Hallo, Hola, Bonjour, Olá, Ciao! 👋 | Global Discussions
-
I think there were other issues that made the formula become an error.
Last question; how do I format an options group using a format shown below? This is causing me grief. Not sure why?
$body = '[{"index":25,"title":"Project Type","type":"PICKLIST","options":[\"Expansion\",\"New Logo\"]}]'
-
Going off the example in the API Documentation for updating a column, Picklist options simply need quotes around them, without the \
Try:
"options":["Expansion", "New Logo"]
Cheers,
Genevieve
Need more help? 👀 | Help and Learning Center
こんにちは (Konnichiwa), Hallo, Hola, Bonjour, Olá, Ciao! 👋 | Global Discussions
-
That worked. Much appreciated.
Just curious, I was having an issue with updating columns with formulas throwing errors because the formula contained an column that was not yet imported. Since the data may be from the summary to a sheet formula, and/or from a column formula to a summary, it was causing them to fail even if I had them imported in the proper order at the end of the script. To that end, I wrote the script to first import all columns without formulas, then do an update to all fields which includes the formulas. Is there another way of approaching this, or is that the only solution. Seems to be working, but wanted to ask.
Thanks again!
-
No problem - I'm glad to hear it worked for you! 🙂
The way that you have this currently set up is exactly what I'd suggest: first create/import all columns, then do an update to include the necessary formulas.
Need more help? 👀 | Help and Learning Center
こんにちは (Konnichiwa), Hallo, Hola, Bonjour, Olá, Ciao! 👋 | Global Discussions
Categories
- All Categories
- 14 Welcome to the Community
- Smartsheet Customer Resources
- 63.5K Get Help
- 402 Global Discussions
- 213 Industry Talk
- 450 Announcements
- 4.7K Ideas & Feature Requests
- 141 Brandfolder
- 135 Just for fun
- 56 Community Job Board
- 454 Show & Tell
- 31 Member Spotlight
- 1 SmartStories
- 296 Events
- 36 Webinars
- 7.3K Forum Archives