Basic CURL hello world:
Get Curl from: https://curl.haxx.se/download.html
I used the Windows 64 generic CAB file version.
Unzip into a Windows Folder locally. I used D:\curl-7.54.1\
Open a command line to the Windows folder: D:\curl-7.54.1\I386\curl.exe
curl --insecure --user brolly: P@s5W0rd https://brolly.com:52311/api/query?relevance=(names%20of%20bes%20computers)
--insecure (or -k) for insecure (because my BES root server uses the default self signed certificate) . Production code will want to import the root CA to make it available to cURL so you can get rid of this insecure workaround.
--user (or -u) this is using basic auth by passing BESConsoleOperatorName:Password
URL includes URL encoded query (see those %20 instead of spaces?)
Note: https://brolly.com:52311 does not exist - use your own BigFix server address and port (usually 52311) for this.
Improvements to this basic syntax:
curl -k -u brolly33:P@s5W0rd -X POST -d "relevance=(names of bes computers)" https://brolly.com:52311/api/query
We have added the explicit POST method using -X POST.
We have separated our URL from our data to post, allowing for embedded spaces without URL encoding in our query, using the -d. Note that double quotes still need to be encoded in this part (%22)
We are using the shorter flags for less typing (-u instead of --user)
Even better, getting a cookie for 24 hours of Authentication, so you don’t have to pass the password in plaintext more than once:
curl --cookie cookie.txt --cookie-jar cookie.txt --insecure --user brolly33:P@s5W0rd https://brolly.com:52311/api/login
or with short commands
curl -b cookie.txt -c cookie.txt -k -u brolly33:P@s5W0rd https://brolly.com:52311/api/login
Now I can use this method instead until the cookie expires with the server:
curl -k -b cookie.txt -X POST -d "relevance=(names of bes computers)" https://brolly.com:52311/api/query
More API commands direcly on your own server here:
curl --insecure --user brolly: P@s5W0rd https://brolly.com:52311/api/help
And documentation here: https://developer.bigfix.com/rest-api/
Note, if you don't use the -k or --insecure, you will probably get error:
curl: (77) schannel: next InitializeSecurityContext failed: SEC_E_UNTRUSTED_ROOT (0x80090325) - The certificate chain was issued by an authority that is not trusted.