i know how to use curl to do a query to retrieve records but how do i then update said records using curl?
i've searched the forums and havent found any posts on this.
Here's a curl command line to set a custom property on a node:
curl -u myusername:mypassword -k -H "Content-Type: application/json" -d '{"City":"Vienna"}' https://myservername:17778/SolarWinds/InformationService/v3/Json/swis://myservername/Orion/Orion.Nodes/NodeID=11/CustomProperties
How did you figure out the curl command? I was trying to create a curl command to create a group (container) with a simple member definition based on a custom property but I couldn't quite get the syntax correct. Is there an easy way perhaps using SWQL studio to get the curl syntax right?
this is what I was trying - I didn't get any errors back but I also didnt get any new containers created either...
curl.exe -k "">solarwinds.mycompany.com:17778/.../CreateContainer"
--request POST
--data "[\"Server Admins\",\"Core\",60,0,\"\",true[\"name\":\"Group_Name CP is 'Server Admins'\",\"Definition\":\"filter:/Orion.Nodes[CustomProperties.Group_Name='Server Admins']]]\" --user admin:password
First, a curl tip - if you are not getting the results you want, add "-v" to the command line. By default, curl won't print anything except the server response body. With "-v" you will get a bunch more info, including the server response code.
Next, curl is not the world's most friendly tool for sending complex post data on the command line. I find python much more friendly for this kind of work. (https://github.com/solarwinds/orionsdk-python).
Here's a curl command line that works:
curl.exe -k "https://solarwinds.mycompany.com:17778/SolarWinds/InformationService/v3/Json/Invoke/Orion.Container/CreateContainer" --request POST --data "[\"Server Admins\",\"Core\",60,0,\"\",true,[{\"name\":\"Group_Name CP is 'Server Admins'\",\"Definition\":\"filter:/Orion.Nodes[CustomProperties.Group_Name='Server Admins']\"}]]" --user admin:password -H "Content-Type: application/json"
I made a few changes:
* Add the missing comma after "true" in the argument list
* Wrap the name/definition pair in braces { } since it is a json object
* Remove the \ on the final closing " character
* Add a Content-Type header since SWIS needs to know you are sending json
Holy smokes thank you this is awesome! I'll take a look at python.
I thought I had tried curly braces before but I was using your example from another post actually where you showed brackets, but I was trying everything, brackets, curly braces etc... didn't catch that comma mistake though, its always the little things...
Again, thanks for your help, you seem to be THE man for the SDK! I'm trying new things and experimenting with trying to make my life easier by scripting a migration from Whats up gold to solarwinds using the API, might have some more questions for ya if you don't mind. (in a new thread of course)
SolarWinds solutions are rooted in our deep connection to our user base in the THWACK® online community. More than 195,000 members are here to solve problems, share technology and best practices, and directly contribute to our product development process.