I'm using CURL to execute some API calls against a bitbucket server. The command is like this:
curl https://bitbucket.myserver.com/rest/api/1.0/projects/PRJ/repos/repo-slug/tags \
-u 'user:pass' \
-X POST \
-H 'Content-type: application/json' \
-d '{"name" : "test-tag", "message": "Test tag from curl", "startPoint": "master" }'
This is expected to create a tag on the master branch in the repo. This however fails complaining of incorrect username/password.
I then copy/paste the command into git-bash prompt - and it works as expected, completing successfully. I tried this with multiple user accounts. I also tried specifying only the username and then entering the password on command line - with the same results.
How can I get curl on windows to pass correct username/password to the server?
Related
I am a noob at all this and I am trying to run a Linux curl command in Windows 10 to generate session key. The following is the command in Linux.
curl -H "Content-Type: application/json" -d '{"id":1, "jsonrpc":"2.0", "method": "author_rotateKeys"}' http://localhost:9933/
When I run the command at the Windows command prompt I am receiving the following error.
E:\>curl -H "Content-Type: application/json" -d '{"id":1, "jsonrpc":"2.0", "method": "author_rotateKeys"}' http://localhost:9933/
curl: (3) URL using bad/illegal format or missing URL
curl: (3) URL using bad/illegal format or missing URL
curl: (3) unmatched close brace/bracket in URL position 18:
author_rotateKeys}'
^
E:\>
Any idea how would I covert the command to work with Windows 10? I just need to generate a key for a node I need to connect to from a Windows box.
If you don't have WSL2 setup (useful if you ever need other *nix tools) where that command will just work as is, or don't want to use PowerShell where
curl.exe -H "Content-Type: application/json" -d '{"id":1, "jsonrpc":"2.0", "method": "author_rotateKeys"}' http://localhost:9933/
works (notice the curl is replaced with curl.exe, because in PowerShell 5.1 curl is just an alias for Invoke-WebRequest, it's removed in PowerShell 6 and later, but they're not built-in and won't replace PowerShell 5.1 when installed), then on Command Prompt replace single quote with double quote, and for double quote inside them, escape it (replace it with \")
curl -H "Content-Type: application/json" -d "{\"id\":1, \"jsonrpc\":\"2.0\", \"method\": \"author_rotateKeys\"}" http://localhost:9933/
I'm trying to automate github pull requests via bash script, specifically raising pull requests for forked branches. I've successfully done it for private repos, however it doesn't seem to work for public repos (see code below):
curl -H "Authorization: bearer <accesstoken>" -d '{"title":"SOMETITLE","base":"master","head":"'"someuser"':'"someForkedBranch"'","body":"some words to fill body."}' https://api.github.com/repos/<user-name>/<repo-name>/pulls
Any help would be appreciated.
If this is for creating a PR, you would need a -X POST somewhere in your curl command, in order to POST the query for a new PR:
curl \
-X POST \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/octocat/hello-world/pulls \
-d '{"head":"head","base":"base"}'
Make sure also to use the right oauth/PAT or SAML SSO:
curl -v -H "Authorization: token TOKEN" -X POST ...
Those token have just seen a new format update (Apr. 2021) so you might need to regenerate one.
I have an SMTP configuration like the follows: (everything is dummy data)
SMTP_USERNAME="fakenews#yahoo.comg"
SMTP_SERVER="smtp.office365.com"
SMTP_PASSWORD='rdjsllskdslsds!'
SMTP_PORT="587"
EMAIL_FROM="support#fakernews.com"
EMAIL_TO="rfakeuser#fakernews.com"
Note the "!" mark at the end of the password. This cannot be changed.
When I run the below command with everything hardcoded, it works fine, and an email is sent.
curl --url smtp://smtp.office365.com:587 --mail-from support#fakernews.com --mail-rcpt rfakeuser#fakernews.com --upload-file tempemailbody_1.txt --user fakenews#yahoo.comg:rdjsllskdslsds! --ssl
However, when I replace them with variables, as below, I keep getting access denied.
curl --url "smtp://$SMTP_SERVER:$SMTP_PORT" --mail-from $EMAIL_FROM --mail-rcpt $EMAIL_TO --upload-file tempemailbody_1.txt --user "$SMTP_USERNAME:$SMTP_PASSWORD" --ssl
The error message is :
curl: (9) remote access denied: 501
I think that this is because somehow the variable interpretation is causing the issue, but I cant figure out what is it. What should I change in the command to make it work ?
I'm running Jenkins pipeline job on a windows 10 agent.
i'm trying to publish some information from the agent to confluence.
Running with script.bat:
curl --fail --silent --show-error -u ****:**** -X GET <SomeInternalAddress>
works!
but running:
curl --fail --silent --show-error -u ****:**** -X POST -H 'Content-Type: application/json' -d '#tmpCurlPostData.txt' <SomeInternalAddress>
results with:
curl: (6) Could not resolve host: application
curl: (22) The requested URL returned error: 415
tried escape a '=' in the password with '^'. tried surrounding with quotes.
but with no success.
interesting fact, the same code works fine on win 7,
testing it on a new win 10 machine revealed the problem.
would appreciate any idea guys.
thanks a lot!
https://www.ibm.com/support/knowledgecenter/SSBS6K_2.1.0/apis/auth_manage_api.html
I try to use the API for common user integrated with OIDC, but the error msg shows:
{"error_description":"invalid_resource_owner_credential","error":"server_error"}
command as the following
curl -k -H "Content-Type: application/x-www-form-urlencoded;charset=UTF-8" -d "grant_type=password&username=abc\#test\.com&password=ChangeMe\!\#\#&scope=openid" https://<cluster_access_ip>:8443/idprovider/v1/auth/identitytoken --insecure
But it is working fine for the administrator: admin/admin, so strange.
Issue is with the special character "!" which is used for history expansions in command line prompt.
You can use below command which works...
curl -k -H "Content-Type: application/x-www-form-urlencoded;charset=UTF-8" -d "grant_type=password&username=abc#test.com&password=ChangeMe"'!'"##&scope=openid" https://<cluster_access_ip>:8443/idprovider/v1/auth/identitytoken --insecure
Have you configured the LDAP, created Teams and added users to the team? Did you check the logs on Master node /var/log/containers for platform-identity-manager, _platform-auth-service, *platform-identity-provider?