curl with REST API - rest

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/

Related

How to channel originate SIP in Asterisk ARI?

I try to make call via Asterisk REST API, I want to make a call like this (CLI command example):
channel originate SIP/4444#sipprovider application playback tt-monkeys
I try to use curl for that:
curl -v -u admin:pass -X POST "http://127.0.0.1:8085/ari/channels?endpoint=SIP/1000&extension=4444&context=sipprovider"
When I post the request I get this error:
Allocation failed
What did I do wrong?
If I try using SIP, I get the same error. You might have PJSIP enabled instead of SIP.
Try using PJSIP instead of SIP.
Example:
curl -v -u asterisk:asterisk -X POST "http://localhost:8088/ari/channels?endpoint=PJSIP/5001&extension=5002&context=internal"

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

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.

IBM Cloud API Docs Tone Analyzer

I tried to implement :
curl -u "apikey:{apikey}" "{url}/{method}"
resorce:https://console.bluemix.net/apidocs/tone-analyzer
My question what I need to do? I already have the api key, for example 1234,
and my url is https://gateway.watsonplatform.net/tone-analyzer/api
First what is the: {method} in the above cURL request and what do I need to do with that?
Question 2 this is correct?:
curl -u "apikey:1234" "https://gateway.watsonplatform.net/tone-analyzer/api/{method}
In the cURL request below:
curl -X GET -u "apikey:{apikey}" "https://gateway.watsonplatform.net/tone-analyzer/api/v3/tone?version=2017-09-21&text=Team,%20I%20know%20that%20times%20are%20tough!%20Product%20sales%20have%20been%20disappointing%20for%20the%20past%20three%20quarters.%20We%20have%20a%20competitive%20product,%20but%20we%20need%20to%20do%20a%20better%20job%20of%20selling%20it!"
The {URL} is https://gateway.watsonplatform.net/tone-analyzer/api and {method} is /v3/tone. To under the endpoint, check this link
You are making a GET method call and for this, you need to create a service at https://console.bluemix.net/catalog/services/tone-analyzer
For more information on how to get an API key, refer to this link

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

Correcting SOAP Fault Method not Implemented Errors

OK, not sure what this problem is. I am trying to post an API request to PayPal via cURL and I get the following result. Is there something that I am missing in my call that would cause this?
According to PayPal, the call is correct and it works fine when I use the PHP cURL wrapper functions...Weird.
Thanks for helping!
curl https://api.sandbox.paypal.com/2.0/ -H "X-PAYPAL-SECURITY-USERID: api1.sitetest.com" -H "X-PAYPAL-SECURITY-PASSWORD: 111222222UH24" -H "X-PAYPAL-DEVICE-IPADDRESS: 170.10.125.52" -H "X-PAYPAL-MESSAGE-PROTOCOL: SOAP11" -H "X-PAYPAL-APPLICATION-ID: APP-80W284485P519543T" -E "/Users/Me/Library/PayPal_Keys/cert_key_pem.txt" -d "<SOAP-ENV:Envelope xmlns:xsi=\"http://www.w3.org/1999/XMLSchema-instance\" xmlns:SOAP-ENC=\"http://schemas.xmlsoap.org/soap/encoding/\" xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsd=\"http://www.w3.org/1999/XMLSchema\" SOAP-ENV:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\"><SOAP-ENV:Header /><SOAP-ENV:Body><CreateAndSendInvoiceRequest><requestEnvelope><errorLanguage>en_US</errorLanguage></requestEnvelope><invoice><merchantEmail>sweet#sweetsounds.com</merchantEmail><payerEmail>me#testsite.com</payerEmail><businessName>Test Business, Inc.</businessName><logoURL></logoURL><itemList><item><name>Test Item</name><quantity>2</quantity><unitPrice>5.79</unitPrice><taxName>sales</taxName><taxRate>6.0</taxRate></item></itemList></invoice></CreateAndSendInvoiceRequest></SOAP-ENV:Body></SOAP-ENV:Envelope>"
Returns
<SOAP-ENV:Fault><faultcode>SOAP-ENV:Client</faultcode><faultstring>Method not implemented</faultstring></SOAP-ENV:Fault>
Solved this. PayPal changed the sandbox api url for this particular call and did not update that in their docs.
new url for sandbox is "https://api-3t.sandbox.paypal.com/2.0/". You can test your commands here