Not able to create a project using rest api
Asked by Aman Tur:

I'm trying to create a project using REST API. Every time I'm getting internal server error like this:

{  
"type": "error",  
"error": {  
"message": "Something went wrong",  
"id": "0bd3a5f302e843fda412d6416a17beef"  
}  
}  
EDIT: URL <https://api.bitbucket.org/2.0/workspaces/>\<workspace\>/projects


Answers:
author: Caroline R
body: Hi, Aman, thank you for reaching out to Atlassian Community.

I tested this on my side and was able to create a project using the following API:

* <https://developer.atlassian.com/cloud/bitbucket/rest/api-group-projects/#api-workspaces-workspace-projects-post>

Here is an example that you can follow, you just need to inform your **workspace ID** , the project **name** , and the **key** you would like to create:

```
curl --request POST -u username:AppPassword \
--url 'https://api.bitbucket.org/2.0/workspaces/{workspace_ID}/projects' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--data '{
"key": "{inform_a_key}",
"name": "{project_name}",
"is_private": true
}'
```

Please let me know how it goes and feel free to share any additional questions or concerns regarding this case.

Kind regards,   
Caroline
> Our annual user conference, Team '22 is back! Join us in Las Vegas starting April 5th or attend digitally on April 6th. Register now: <https://events.atlassian.com/team22>


author: David Bakkers
body: Hello [@Aman Tur](/t5/user/viewprofilepage/user-id/4761439)

You've probably submitted an invalid request.

comments: author: Aman Tur
body: The payload is from the example:

```
{
"name": "CloudX",
"key": "CEX",
"description": "This Project is for the CloudX.",
"is_private": true,
"has_publicly_visible_repos": false,
"type": "project",
"uuid": "c35b960d-3c0e-467b-81d4-b43368beac96",
"links": {
"avatar": {
"href": "https://.../default.png"
}
}
}
```


author: David Bakkers
body: You haven't provided any information as to which Bitbucket REST API endpoint you're sending that request to or the method, so I'll have to guess.... you're sending a POST request to:

```
/2.0/workspaces/{workspace}/projects
```

You haven't advised if the request works if you omit all the un-required parameters and just define the required ones like `name`, `key`, `is_private` and `description`, so I'll have to guess... you haven't tested that.


author: Aman Tur
body: Hi [@David Bakkers](/t5/user/viewprofilepage/user-id/1575730),

I've tried only required parameters and still getting the same. I've updated the URL in question as well.


author: David Bakkers
body: I'm able to create projects in one of the workspaces of my Bitbucket Cloud account using that REST API endpoint with only those required parameters without any errors.

Nobody else seems to be reporting any problems with Bitbucket Cloud's REST API, so if it's affecting just you and just that REST API endpoint and no others, and you've tried all the obvious usual things like:

* Testing with another OAuth key / token
* Checking with another method (different dev tool / language)
* Checking with a test tool like Postman

...and the error persists, I suggest you raise a support request with Atlassian.

Good luck.


author: Aman Tur
body: I'm using Postman already, but using another access key does look promising.


Tags: bitbucket-cloud

cloud

rest-api