Is it possible to run a curl command with a splunk dbxquery? - rest

I am developing a dashboard that connects to Splunk via REST API and displays data on various charts/graphs etc. In order to get the data I have to make a POST request via curl (node.js). Everything is working great. However when I try to make a Post request with a dbxquery, it fails and returns 'fatal dbxquery unknown command.' I was wondering if anyone had encountered this before.
curl -H 'Authorization: Basic auth token' -k https://devfg.com:8089/services/search/jobs -d search=" | dbxquery query=\"SELECT count(*) FROM db.table\" connection=\"connection\"" -d output_mode=json

Are the permissions for the dbxquery command set to be executable from any app? Check under app permissions to see if the command is globally exported.
Alternatively, you may need to escape the *, so \*.
Otherwise, you should be able to run the dbxquery via a curl command.

Related

Sending mail with curl on Windows via MS Exchange Server

I am trying to send an email using curl on Windows 10 through an MS Exchange Server. The email is sent to another user in the same Active Directory domain, and the user who is sending the email is already authenticated under Windows.
Given the above, I can successfully send an email using telnet as follows:
or PowerShell as follows:
Given that the above two commands work, I am looking for the equivalent curl command. I have looked at the following SO answer:
Using curl to send email
and tried the following command (and many other combinations of options), but with no success.
curl -v --url "webmail.jXs.com:25" --mail-from "r#jXs.com" --mail-rcpt "s#jXs.com" --upload-file mail.txt
I get the following output:
where the mail.txt file is:
So, what is wrong with my curl command? Thanks.
Apparently when using curl, we have to specify the smtp communication protocol in the url (which is not necessary when using telnet or powershell). So, adding smtp:// to the url made the curl command work.
curl -v --url "smtp://webmail.jXs.com:25" --mail-from "r#jXs.com" --mail-rcpt "s#jXs.com" --upload-file mail.txt

Bluemix - Natural Language Classifier credentials in the Questions on classifier demo

I'm trying to use IBM Watson Natural language Classifier but I can't proceed and load my answers. For some reason, username and password aren't working all the time.
This one executed fine:
curl -u username:password -F training_data=#questions.csv -F
training_metadata="{\"language\":\"en\",\"name\":\"my_classifier\"}"
"https://url/v1/classifiers"
But when I try to execute the following command, it doesn't work:
curl -u username:password -X POST -H "Content-Type: application/json"
-d #questions-with-classifier-ega-war/target/classes/answers.json http://yourAppName.mybluemix.net/api/v1/manage/answer
It just asks for the user and password again and again. It is the same password that just worked in the first curl command.
Thanks in advance!
I think you are confusing the service credentials (the one you use in the first command) with the credentials used to manage the database in one of the sample applications "Questions on Classifier" (see pom.xml).
In order to run your second command make sure you use the credentials from the pom.xml in your root directory

Example REST Extension does not xdmp:log anything when invoking POST

I trying to debug a REST extension in MarkLogic by using xdmp:log() inside the XQuery. Seems I am having some issues invoking a POST call in general actually...? Bit confused now.
I use the exact example code as from the MarkLogic documentation here
I installed it via Roxy > deploy > ext
It is there when I look into http://host:port/v1/config/resources
The PUT command provided in the doc works and returns the "Done".
But I cannot get the POST statement to dump the xdmp:log messages in the errorlog.txt on the server?
I tried several curl commands:
curl --anyauth --user admin:admin -X POST http://host:8040/LATEST/resources/example
curl: (52) Empty reply from server
Question: What is the correct curl command to trigger the examples POST functon so something shows up in the log?
This is a curl issue. You need to specify a request body for curl to send.
curl --anyauth --user admin:admin -X POST -d '{"key":"value"}' http://host:8040/LATEST/resources/example
Or if you want to send an empty body just do this:
curl --anyauth --user admin:admin -X POST -d '' http://host:8040/LATEST/resources/example

ApiAxle: cannot access stat URL in order to view analytics

I am following the instructions at: http://apiaxle.com/docs/statistics-and-analytics-in-apiaxle/ . Unfortunately currently (May 17, 2014) apiAxle is redirecting me to the endPointserver and I am not getting statist
menelaos:~$ curl 'http://localhost:3000/v/api/test/stats?
granularity=hour&format_timestamp=ISO'
Response:
{"meta":{"version":1,"status_code":404},"results":{"error":
{"type":"ApiUnknown","message":"No api specified (via subdomain)"}}}
I also tried using the subdomain but that didn't work either:
menelaos:~$ curl 'http://test.api.localhost:3000/v/api/test/stats?granularity=hour&format_timestamp=ISO'
Typically you run multiple instances of apiaxle-proxy (which provides access to your endpoints), and a single instances of apiaxle-api (which provides access to statistics, key creation, and other API management functionality).
For example, you might be running the proxy like this:
apiaxle-proxy -f 1 -p 3000 -q
To run the API, you would run something like this:
apiaxle-api -f 1 -p 5000 -q
Note that the API needs to run on a separate port. Also note that it shouldn't be accessible to the outside world as it doesn't have any authentication.
Using the above example, your curl command would look like this:
curl -H 'content-type: application/json' \
-X GET \
'http://localhost:5000/v1/api/test/stats' \
-d '{"granularity":"hour","format_timestamp":"ISO"}'
Note that the parameters need to be sent as JSON.

curl with REST API

I want to test an API using curl for Mac.
According to the REST API documentation/forums, the URL should look like this:
http://localhost:8080/sdpapi/request/?OPERATION_NAME=ADD_REQUEST&<your API key>&<Operation> <Details><requester>Me</requester><subject>Test</subject><description>Testing Curl Input</description></Details></Operation>
Here is what I have come up with for the curl command line input:
curl -X POST -d "OPERATION_NAME=ADD_REQUEST&TECHNICIAN_KEY=0...87&INPUT_DATA=<Operation><Details><requester>Me</requester><subject>Test</subject><description>Testing curl input</description></Details></Operation>" http://myserver.mydomain.org/sdpapi/request/  
I haven't tried it yet because I am BRAND NEW to this and I'm sure there are problems. Does this look OK and should I give it a whirl?
Figured it out: curl -d "OPERATION_NAME=ADD_REQUEST&TECHNICIAN_KEY=xxxxxxxxxx&INPUT_DATA=TestData.xml" http://xxx.xxx.xx.xx/sdpapi/request/