I try to use curl to get list of projects on my JIRA:
curl -u myusername:mypassword http://myjira.com/rest/api/2/project
and it return an empty array without error
I use Postman (a Google Chrome app) to call that request using Basic authentication, it also return an empty array
If I login into my JIRA site and use Postman to call the API again, it return a full list of
project because it used Cookie that was generated after my login.
So I think the Basic Authentication does not work. Can anyone please help?
Is your JIRA behind some proxy server? Proxy servers can eat the basic auth credencials.
If that's the case, then you need to initialize session using POST request to /rest/auth/1/session: https://docs.atlassian.com/jira/REST/latest/#idp1478624 After doing that you can use REST as logged in user if you pass session cookies properly.
One liner to login and get project, without basic auth:
# -c option makes curl write cookies from response to given file # -b option makes curl send cookies from given file in request curl -c cookiesfile http://localhost:8090/jira/rest/auth/1/session -d '{"username":"admin", "password":"admin"}' -H 'Content-Type: application/json' -X POST && echo -e "\n-----------------\n" && curl -b cookiesfile http://localhost:8090/jira/rest/api/2/project
what is & in your code?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
"&" is just the '&' character. So you can just replace them with '&'.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
If my username contains @ sign what i need to do
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Another addition to this thread (as I've also been looking as to why basic auth was not working also), remember your email address is not the username. I've been attempting authentication (unsuccessfully) with REST api and basic auth using my email address because it is what I use to signin to JIRA and made an incorrect assumption in my haste. I'm feeling a little silly after that one, but it might be catching other people too.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Bruce, you helped me to prevent a concussion from banging my head against the wall. Thank you sir.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
^--- this guy saved my life
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I already read that note and try to use send username and password both via -u parametter or via header using base64 encode of username:password. However, no matter what I try, it still return an empty array.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
How would you do this via Jquery/AJAX and getting around the lack of CORS support for the JIRA REST API?
cURL command works fine for me but what's the point when I need the project information I need via JavaScript.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I also have this problem. Without the availability of JSONP or CORS, the only solution left is to call the service from serverside code instead of javascript.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Aleksander Mierzwicki: You are right. It is because of the proxy server. Your solution is exactly what I need. Thank you so much
I really appreciated all your help
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I have clean fresh JIRA instance.
To check I did exactly curl -u user:password http://localhost:8090/jira/rest/api/2/project
I've got empty array then realized I forgot to add any project...
After adding project this curl just works.
Maybe you use different version of JIRA than I do?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
What you entered may not work. Please read this note.
https://developer.atlassian.com/display/JIRADEV/JIRA+REST+API+Example+-+Basic+Authentication
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.