Missed Team ’24? Catch up on announcements here.

×
Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

How to create project through API

Umar Draz August 19, 2019

Hello

How I can create Project using API?

I had try this one

 

https://developer.atlassian.com/bitbucket/api/2/reference/resource/teams/%7Busername%7D/projects/

 

But getting this a out put after running the bash script.

 

< HTTP/2 401

< server: nginx

* Authentication problem. Ignoring this.

< www-authenticate: Basic realm="Bitbucket.org HTTP"

< content-type: text/html; charset=utf-8

< strict-transport-security: max-age=31536000; includeSubDomains; preload

< date: Mon, 19 Aug 2019 16:22:42 GMT

< x-served-by: app-159

< x-static-version: 2f8d6eb2653c

< etag: "d41d8cd98f00b204e9800998ecf8427e"

< x-render-time: 0.199751138687

< x-version: 2f8d6eb2653c

< x-request-count: 139

< x-frame-options: SAMEORIGIN

< content-length: 0

 

Would you please some body help me.

1 answer

1 accepted

1 vote
Answer accepted
Ana Retamal
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
August 20, 2019

Hi Umar, welcome to the Community!

Thank you for your question and for showing us the output you're receiving. To help you with this, we'll need to know what request are you sending to Bitbucket, can you show us the exact command you're using?

Also, note that projects are only available for teams, so you should be creating it in a Team account and not an individual account. Your user also needs to have the necessary permissions to create projects in the team.

Cheers,

Ana

Umar Draz August 20, 2019

Hi Ana,

 

Thanks for your reply here is my complete code

 

body=$(cat << EOF

{

    "name": "UDZ",

    "key": "UDZ",

    "description": "Umar Draz Api Testing",

    "links": {

        "avatar": {

            "href": "http://icons.iconarchive.com/icons/guillendesign/variations-3/256/Default-Icon-icon.png"

        }

    },

    "is_private": true

}

EOF

)



curl -v -u myusername:mypassword -H "Content-Type: application/json" \

-X POST \

       -d "$body" \

       https://api.bitbucket.org/2.0/teams/<team_name>/projects/ 

The username, password and team name is dummy, because I can not share here.

Ana Retamal
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
August 23, 2019

Hi Umar,

I've tried reproducing this issue using the code you provided and it worked for me. You can see my output here:

curl -D- -u USERNAME:APP-PASSWORD -H "Content-Type: application/json" -X POST -d '{"name":"UDZ","key":"UDZ","description":"Umar Draz Api Testing","links":{"avatar":{"href":"http://icons.iconarchive.com/icons/guillendesign/variations-3/256/Default-Icon-icon.png"}},"is_private":true}' https://api.bitbucket.org/2.0/teams/TEAM-NAME/projects/

HTTP/2 201
server: nginx
vary: Authorization
[…]

{
 "description": "Umar Draz Api Testing",
 "links": {
   "self": {
     "href": "https://api.bitbucket.org/2.0/teams/TEAM-NAME/projects/UDZ"
[....]
}

 

This confirms that the code you're using is correct, and the issue must rely on the authentication, as outlined in the error message in the response header you provided:

< HTTP/2 401

Once you re-try the steps, make sure the authentication is correct by completing the following: 

  1. Make sure you're using the right credentials, they must be your username and an App password (not your personal password).
  2. The App password needs to have the right permissions for the project. If you don't remember if you granted it the right permissions, I'd suggest you create a new App password, the instructions can be found at App passwords
  3. Your user must also have permissions to access the team and create projects.

 Let us know how it goes!

Cheers,

Ana

Umar Draz August 23, 2019

Hi Ana,

 

The App password worked. Thanks for your help :)

Ana Retamal
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
August 23, 2019

So glad to hear that, Umar.

Have a great weekend :)

Ana

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events