HTTP request equivalent of lb web-client import --full - logicblox

How can I achieve the same functionality as lb web-client import --import file.csv --full http://service-uri with an HTTP request made with a tool like cURL?

If you want to update data, you can use:
curl -i -X POST -H "Content-Type: text/csv" --data-binary #file.csv http://service-uri
or if you want to replace data, you can use:
curl -i -X PUT -H "Content-Type: text/csv" --data-binary #file.csv http://service-uri

Related

ADO Linking requirement & test case work items with Rest API issue

I'm trying to link a ADO Requirement work item to a ADO Test Case work item. I'm making this call:
curl -u :********** -X PATCH -H "Content-Type: application/json-patch+json" -H "Accept: application/json-patch+json" -d "[{{\"op\": \"test\", \"path\": \"/rev\",\"value\": 3 },{\"op\": \"add\", \"path\": \"/relations/-\", \"value\":\"{\"rel\": \"System.LinkTypes.Dependency-forward\",\"url\": \"https://***.***.com/{Organisation}/_apis/wit/workItems/{ID}\",\"attributes\": {\"comment\": \"Making a new link for the dependency\"}}}}]" https://***.***.com/{Organisation}/{Project}/_apis/wit/workItems/{ID}?api-version=6.0
as per: https://learn.microsoft.com/en-us/rest/api/azure/devops/wit/work-items/update?view=azure-devops-rest-7.1#add-a-link
But I'm having this error:
{"$id":"1","innerException":null,"message":"You must pass a valid patch document in the body of the request.","typeName":"Microsoft.VisualStudio.Services.Common.VssPropertyValidationException, Microsoft.VisualStudio.Services.Common","typeKey":"VssPropertyValidationException","errorCode":0,"eventId":3000}
I found my answer, the JSON was badly parse. I used a online JSON linter to fix it. https://jsonlint.com/
curl -u :********** -X PATCH -H "Content-Type: application/json-patch+json" -H "Accept: application/json-patch+json" -d "[{\"op\": \"add\", \"path\": \"/relations/-\", \"value\":{\"rel\": \"Microsoft.VSTS.Common.TestedBy-Forward\",\"url\": \"https://***.***.com/{Organisation}/_apis/wit/workItems/{ID}\",\"attributes\": {\"comment\": \"Making a new link for the dependency\"}}}]" https://***.***.com/{Organisation}/{Project}/_apis/wit/workItems/{ID}?api-version=6.0

Cannot import grafana dashboard via grafana HTTP API

I am trying to import existing json file using HTTP API, but the 'curl' command throwing the error.
I am using the below command to import existing json file,
curl --user admin:admin "http://localhost:3000/api/dashboards/db" -X POST -H "Content-Type:application/json;charset=UTF-8" --data-binary #/u04/sys_monitor/my_Metrics.json
If i run the above command, it is throwing the error like "[{"fieldNames":["Dashboard"],"classification":"RequiredError","message":"Required"}]"
I tried to run the below command,
curl --fail --insecure --user admin:admin --request "POST" "http://localhost:3000/api/dashboards/db" --header "Content-Type: application/json" --data-binary #/u04/sys_monitor/my_Metrics.json
For the above command execution i am getting the error like,
curl: (22) The requested URL returned error: 422 Unprocessable Entity
Where i am doing wrong, kindly assist me,
The below comment is working but not updated the dashboard in grafana,
curl --user admin:admin -vvv "http://localhost:3000/api/dashboards/db" -X POST -d #My_Metrics.json -H 'Content-Type: application/json'

curl no URL specified using POST

From a shell, I'm trying to use the REST API for Fedora Commons to upload a binary to a particular location using curl:
curl -X PUT --upload-file image.jpg -H "Content-Type: image/jpeg" -H "http://localhost:8080/rest/TestUpload/newexcel"
The error I'm getting:
curl: no URL specified!
Following instructions from here:
https://wiki.duraspace.org/display/FEDORA471/RESTful+HTTP+API
-H is for extra header to include in the request when sending HTTP to a server and you should not use it before the url.
You probably need to do curl -X PUT --upload-file image.jpg -H "Content-Type: image/jpeg" http://localhost:8080/rest/TestUpload/newexcel

curl calling REST API response into a file

I am using curl to call a REST API. The REST call returns a file mar21.tar.gz
But the format of the file is data but it has to be in gzip format for me to run tar -xvf on it.
How can I get the file to save in the original format in which it is returned.
curl -u #{user}:#{password} -k -i -H "Content-type: application/json" -o #{tmp_dir}/#{filename} -X GET #{url}
Try this:
curl -u #{user}:#{password} -k -i -H "Content-type: application/json" -o #{tmp_dir}/#{filename} -X GET #{url} > mar21.tar.gz

Calling an PingAccess APIs from Powershell

I am trying to call PingAccess APIs to configure my PingAccess.
I am new to using APIs to do this, and have a question.
I am trying to use CURL to the API .
curl -k -u Administrator:dummypsswd -H "X-Xsrf-Header: PingAccess" -H "Content-Type: application/json" -d '{"alias":"PLACEHOLDER_STAR_MINGLE","fileData": [[System.IO.File]::ReadAllBytes("C:\test.pfx")],"password": "1234"}' https://localhost:9000/pa-admin-api/v1/keyPairs/import -v
When I run this I get the following error.
I still dont know why am I unauthorized. Any help is appreciated.
When you have special characters in your password you'll need to enclose the username/password tuple in double quotes:
curl -k -u "Administrator:dummypsswdwithspecialcharslike&&" -H "X-Xsrf-Header: PingAccess" -H "Content-Type: application/json" -d '{"alias":"PLACEHOLDER_STAR_MINGLE","fileData": [[System.IO.File]::ReadAllBytes("C:\test.pfx")],"password": "1234"}' https://localhost:9000/pa-admin-api/v1/keyPairs/import -v