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
Related
Under Geoserver, How do we create the WMTSLayer once the WMTSStore is establish via REST API ?
Trying to follow the swagger documentation under here,
https://docs.geoserver.org/latest/en/api/#1.0.0/layers.yaml
But can't find the correct url to work for it. Get 404 when I try this using curl
curl -v -u admin:geoserver -X POST http://localhost:8085/geoserver-cloud/rest/workspaces/{workspaceName}/wmtsstores/{wmststoreName}/wmtslayers -H "accept: application/json" -H "content-type: application/json" -d "{\"featureType\":{\"name\":\"World_Imagery\"}}"
Also looked under here,
https://docs.geoserver.org/latest/en/api/#1.0.0/wmtslayers.yaml
And tried below url for it. Get 500 when I try this using curl
curl -v -u admin:geoserver -X POST http://localhost:8085/geoserver-cloud/rest/workspaces/{workspace}/wmtsstores/{wmtsstore}/layers -H "accept: application/json" -H "content-type: application/json" -d "{\"featureType\":{\"name\":\"World_Imagery\"}}"
Found it, need to pass wmtsLayer
curl -v -u admin:geoserver -X POST http://localhost:8085/geoserver-cloud/rest/workspaces/{workspace}/wmtsstores/{wmtsstore}/layers -H "accept: application/json" -H "content-type: application/json" -d "{ \"wmtsLayer\": { \"name\": \"NatGeo_World_Map\" } }"
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
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
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
For a remote administration of multiple Glassfish 3.1.2.2 instances I want to configure resource adapter connection pool and connector resources. These configuration can only be done after the resource adapter deployment.
All works if I do things with asadmin.
Get Access via REST works as expected.
Example:
curl --user admin:pwd -X GET -H "Accept: application/JSON"
http://localhost:4848/management/domain/resources/connector-connection-pool
Now I want to create a connection pool using the following command with REST
asadmin create-connector-connection-pool --raname MulticastDNS-connector
--connectiondefinition multicastdns.outbound.MulticastDNSRegistry multicastdns/pool
I followed some of the Oracle examples http://docs.oracle.com/cd/E18930_01/html/821-2416/gjipx.html#gjijx or http://docs.oracle.com/cd/E19798-01/821-1751/gjijx/index.html
But all things I tried got 400 Bad Requests.
Example:
curl --user admin:pwd -X POST -H "Accept: application/JSON" -H "Content-Type: application/json"
-d '{"id":"multicastdn%2fspool","connectiondefinitionname":"multicastdns.outbound.MulticastDNSRegistry","resourceAdapterName":"MulticastDNS-connector"}'\
http://localhost:4848/management/domain/resources/connector-connection-pool -v
# other check
curl --user admin:pwd -X POST -H "Accept: application/JSON" \
-d id=multicastdns%2fpool \
-d connectiondefinitionname=multicastdns.outbound.MulticastDNSRegistry \
-d resourceAdapterName=MulticastDNS-connector \
http://localhost:4848/management/domain/resources/connector-connection-pool -v
Simular results if I want to delete a existing resource.
curl --user admin:pwd -X DELETE -H "Accept: application/JSON" \
http://localhost:4848/management/domain/resources/connector-connection-pool/multicastdns%2fpool -v
# other try
curl --user admin:pwd -X DELETE -H "Accept: application/JSON" \
-d id=multicastdns%2fpool \
http://localhost:4848/management/domain/resources/connector-connection-pool -v
Same issue if try the second step with connector resource
asadmin create-connector-resource --poolname multicastdns/pool jca/multicastdns
Get via REST works but add and delete an entry won't work.
Thanx florian