Calling an PingAccess APIs from Powershell - 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

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

curl no URL specified error, even though URL is being specified

I'm attempting to execute the following CURL call via commandline:
curl -i -H "Content-Type:application/json" \
-u "m19389#dev.acp.co.com:qE2P/N7y1k.\(" \
-X GET -d "https://wefd.it.co.com:3905/events/com.co.mpm.dev.29160-wgdhfgd-v1/dsd/dsdfds-0-0-1-7c49768976-2g7kq"
I've added quotes around the arguments and all, and I'm definitely inclusing the curl url, so I'm not sure what's going on here. Where did I go wrong?

MarkLogic ingest JSON from external API

I am using Marklogic 9 and try to ingest data from external source into MarkLogic. I made an REST API on port 8031. When I try to execute the following curl command:
curl --anyauth --user admin:admin -i -X POST -d https://services7.arcgis.com/21GdwfcLrnTpiju8/arcgis/rest/services/Geluidsbelasting/FeatureServer/0/query?where=1%3D1&outFields=*&outSR=4326&f=json
-H "Content-type: application/json" -H "Accept: application/json" \
'http://localhost:8031
After executing this statement I receive the error:
Curl: URL is not specified
Can you please help me out!
Many thanks
Erik
Your -d parameter has special characters that are not escaped. Try putting quotes around your -d url. It will prevent your command from getting truncated and misinterpreted at & signs..
HTH!

kraken cURL REST API cannot send order saying invalid arguments

I am able to call private user API through code like this:
curl -X POST -H "Accept: application/json" -H "API-Key: mykey" -H "API-Sign: mysign" -d "nonce=123" https://api.kraken.com/0/private/Balance
feedback is telling me how much USD and ETH i have left in my account.
but when I switch to this trying to send order:
curl -X POST -H "Accept: application/json" -H "API-Key: mykey" -H "API-Sign: mysign" -d "nonce=123" 'https://api.kraken.com/0/private/AddOrder?pair=XXBTZUSD&type=buy&ordertype=market&volume=0.01'
it says {"error":["EGeneral:Invalid arguments"]}, how can i fix it?
It seems you need to set the Content-Type header to whatever it is. In this case application/x-www-form-urlencoded. Bit odd that it's not in the docs.

How to create a connector-connection-pool in Glassfish 3.1.2 with REST interface

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