I'm trying to make a script that execute a curl command to create a Rabbit Exchange with Rest API.
If I use --data with the definition like the follow:
HTTP_RESPONSE=$(curl --silent --write-out "HTTPSTATUS:%{http_code}" -u $USR:$PWD --header "Content-Type: application/json" --request PUT --data '{"type": "topic","auto_delete": false,"durable": true,"internal": false,"arguments": {}}' $URL_GENERATE_EXCHANGE)
It runs
But I want to pass the data from a variable like this
EXCHANGE_DEFINITION='{"type": "topic","auto_delete": false,"durable": true,"internal": false,"arguments": {}}'
HTTP_RESPONSE=$(curl --silent --write-out "HTTPSTATUS:%{http_code}" -u $USR:$PWD --header "Content-Type: application/json" --request PUT --data $EXCHANGE_DEFINITION $URL_GENERATE_EXCHANGE)
but It doesn't work...and I don't understand why....Can anyone help me please?
Thank you
Related
I am using Jira cloud and trying to import the Xunit json report (result.json) generated by cucumber to Jira with Xray using Jira rest API, I've tried various ways to import the reports from command line but so far no luck.
Ex:
curl -H "Content-Type: application/json" -X POST -u ID:token -F "file=D:\Report.json" "https://raheel.atlassian.net/api/v2/import/execution"
curl -H "Content-Type: application/json" -X POST -u user:token --data #"D:\Report.json" "https://raheel.atlassian.net/rest/api/3/issue/DEM-9"
curl -H "Content-Type: application/json" -X POST -u user:token --data #"D:\Report.json" "https://raheel.atlassian.net/rest/raven/2.0/api/Test Execution/DEM-12"
**Error:**
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><status><status-code>404</status-code><message>null for uri: https://raheel.atlassian.net/rest/raven/2.0/api/Test%20Execution/DEM-12</message></status>
token=$(curl -H "Content-Type: application/json" -X POST --data #"{ "client_id": "ID","client_secret": "secret" }" https://xray.cloud.xpand-it.com/api/v2/authenticate| tr -d '"') curl -H "Content-Type: application/json" -X POST -H "Authorization: Bearer $token" --data #"D:\Report.json" https://xray.cloud.xpand-it.com/api/v2/import/execution/cucumber
First of all, it seems that you are using Xray Cloud (i.e. Xray for Jira Cloud).
The proper documentation for Xray Cloud's REST API can be found here.
First, you need to create an API key (pair of client id and client secret) on Xray settings.
Then you need to authenticate in order to obtain a token that you'll need to provide in all following requests.
The following example, shows a way of setting a shell variable with the token value, so it can be used in subsequent requests
token=$(curl -H "Content-Type: application/json" -X POST --data #"cloud_auth.json" https://xray.cloud.xpand-it.com/api/v2/authenticate| tr -d '"')
Then you can invoke the REST API endpoint to submit the Cucumber JSON report.
curl -H "Content-Type: application/json" -X POST -H "Authorization: Bearer $token" --data #"Report.json" https://xray.cloud.xpand-it.com/api/v2/import/execution/cucumber
Please note that in order to import Cucumber related results using a cucumber JSON report, your Scenarios need to be properly tagged. You need to follow one of the flows detailed here.
There is POST here which is calling a rest API to fetch the data.
Below is Just the Short code using rest API Call to fetch the data using /rest/resource-alerts, but it only displays max 500 Critical alerts not all. Below is the Code I'm using:
sessionID=$(curl -k -H "accept: application/json" -H "content-type: application/json" -H "x-api-version: 120" -d '{"userName":"administrator","password":"123456"}' -X POST https://synergy.ksg.com/rest/login-sessions | jq -r ".sessionID")
# cUrl command with header and payload information to ftech the Data using API call
CMD=$(curl -k -H 'accept: application/json' \
-H 'content-type: text/csv' \
-H 'x-api-version: 2' \
-H "auth: $sessionID" \
-X
GET https://synergy.ksg.com/rest/resource-alerts)
echo "$CMD"
However, while today going via API DOC I see the Query Parameters , The section says about the count, does anyone know how to get the full list of messages?
Below is the
I am trying to convert a cURL command to AppleScript Using "do shell script".
I've used various hints from previous posts but I'm still running into errors.
Can anyone point out errors in my syntax.
The below script works fine when run in terminal.
curl -X POST https://content.dropboxapi.com/2/files/upload \
--header 'Authorization: Bearer MYTOKEN' \
--header 'Content-Type: application/octet-stream' \
--header 'Dropbox-API-Arg: {"path":"/RoomVT/Clown2.jpeg"}'
--data-binary #"/Splash.jpeg"
I then adapt as.
--Add do shell script Command--
--Place The cURL Inside Double Quotes--
--Replace Double Quotes With Single Quotes--
--Remove Backslashes At End Of Lines--
--You May Also Need To Place All In A Single Line--
do shell script "curl -X POST https://content.dropboxapi.com/2/files/upload --header 'Authorization: Bearer MYTOKEN' --header 'Content-Type: application/octet-stream' --header 'Dropbox-API-Arg: {'path':'/RoomVT/Clown2.jpeg'}' --data-binary #'/Splash.jpeg'"
I still get the error.
"Error in call to API function \"files/upload\": HTTP header \"Dropbox-API-Arg\": could not decode input as JSON"
Thanks for your comments.
I went with #RobC suggestion and it worked first time.
do shell script "curl -X POST https://content.dropboxapi.com/2/files/upload --header 'Authorization: Bearer b4Itg9wetFIAAAAAAAAD7PPkCmoIE2oXvkx_-nq1L2D5G7Bfla-5LHKHtJqoeBMc' --header 'Content-Type: application/octet-stream' --header 'Dropbox-API-Arg: {\"path\":\"/EngineRoomVT/Clown2.jpeg\"}' --data-binary #\"/Splash.jpeg\""
i had a shellscript for export json data but the CURL is getting error malformed..
i'm new for curl anyone can help me please?
this is my cURL
curl -X GET --header "Accept: application/json" --header "Authorization: Basic cm9iZXJ0aDpDMGI0ZDFiN9000" --globoff $JSON_FILE "https://telkomsel.jasperwireless.com/provision/api/v1/sims?export&page=1&limit=3000&sort=monthToDateVoiceUsage&dir=ASC&search=[{"property":"acctId","type":"LONG_EQUALS","value":100090713,"id":"acctId"}]"
please help me
I am testing the following API in RestClient but I am not getting the response because I don't know how to pass the --data "{'myuid':'testuser1'}".
curl -k -v -c cookies.txt -b cookies.txt
-X POST
-H "Content-Type:application/json" -H "Accept: application/json"
--data "{'myuid':'testuser1'}"
"https://<isam address>/mgaapi/sps/apiauthsvc?PolicyId=urn:ibm:security:authentication:asf:mytotp"
I have attached the screenshot as well.
How should I correctly pass the --data "{'myuid':'testuser1'}" in the RestClient to get response from the server?
RestAPI Testing
Try this out with little (proper and required) formatting :
curl -k -v -c cookies.txt -b cookies.txt
-X POST
-H "Content-Type:application/json"
-H "Accept: application/json"
--data '{"myuid":"testuser1"}'
https://<aa>/mgaapi/sps/apiauthsvc?PolicyId=urn:ibm:security:authentication:asf:mytotp
Format is this:
curl -X POST -H "Content-Type: application/json" -d '{"key":"val"}' URL