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.
Related
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
I am trying to follow the documentation from timekit.io. I am attempting to do something as simple as send a curl request to do basic authentication as seen in this section of the docs. I have replaced the Timekit-App:name-of-app with the name of my app which I found in the app-settings of my timekit account. I also replaced the email & password with the one's I use to login into my account.
I simply copied and pasted the curl command as is into my terminal and I get a response that says {"error":"Content-type should be json!"} I am not sure if I am not supposed to copy and paste it as is, or what I may be doing wrong, but my understanding is I am supposed to get a json response with a email and a api token among some other data.
Here is my curl command.
curl -X POST \
-H 'Timekit-App: jl-fit' \
-d '{
"email": "email#email.com",
"password": "password"
}' \
https://api.timekit.io/v2/auth
Looks like you have discovered a bug in their docs/examples.
The API you're connecting to expects JSON content type, but curl by default (for POSTing data) uses application/x-www-form-urlencoded. You can fix it by adding the header field explicitly with: -H 'Content-Type: application/json'.
Also, when you use the -d/--data option, method defaults to POST, so it doesn't have to be specified explicitly.
All put together, this should work:
curl \
-H 'Content-Type: application/json' \
-H 'Timekit-App: jl-fit' \
-d '{"email": "email#email.com", "password": "password"}' \
"https://api.timekit.io/v2/auth"
When having multiple arguments, it can be convenient to keep them in an array (no need to escape newlines). For example:
args=(
-H 'Content-Type: application/json'
-H 'Timekit-App: jl-fit'
-d '{"email": "email#email.com", "password": "password"}'
"https://api.timekit.io/v2/auth"
)
curl "${args[#]}"
I have a URL like below that I use for query
http://<ip>:<port>/api/test/computers?token=a124af&criteria={"and":[["name","=","comp_name"]]}
I was writing a script for this and using curl to download the results from the url. But I am not able to get curl to work. Here is what i tried
curl http://<ip>:<port>/api/test/computers?token=a124af&criteria={"and":[["name","=","comp_name"]]}
-- This runs curl http://:/api/test/computers?token=a124af in background mode.
I know I can pass json data like curl -H "Content-Type: application/json" --data '' . But in this case I have a mix of json as well as other data. How can i achieve that? this does not seem to work
curl -H "Content-Type: application/json" --data "{"and":[["name","=","comp_name"]]}" "http://<ip>:<port>/api/test/computers?token=a124af&criteria="
I wrote this curl command which doesn't seem to work.
curl -H "Content-Type: application/json" -X PUT "Authorization: Bearer {token}" -d "{"login":"user1","password":"xxx"}" https://localhost:8443/users/user1 -k
I tried to change quotation marks but it doesn't work either. All I got is
curl: (6) Could not resolve host: Authorization
{"error":"unauthorized","error_description":"Full authentication is required to access this resource"}
The Authorization works fine though. I'm sure the token is correct.
The -H flag is missing in front of the Authorization header.
Try
curl -H "Content-Type: application/json" -H "Authorization: Bearer {token}" \
-X PUT -d '{"login":"user1","password":"xxx"}' \
https://localhost:8443/users/user1 -k
Because that was missing it was not seeing that as a header, but part of the request URL.
To test, I decode with this in PHP:
var_dump(json_decode(stream_get_contents(fopen('php://input', 'r'))));
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