Bitbucket Data Center - Rest API for import fails with "null for uri" 404 error
Asked by Manoj.S.J:

++**Issue:**++

Using the below command as per the documentation to import or migrate a repository to bitbucket: \[Data Center and Server 7.12 version\]

[https://confluence.atlassian.com/bitbucketserver/importing-957497836.html](https://confluence.atlassian.com/bitbucketserver/importing-957497836.html "Importing")

curl -s -n -u "XXXX:XXXXX" -X POST -H 'Content-type: application/json' -d '{"archivePath":"2021-04-25_15-20-656_mydevopsproject1_nodejs_export.tar"}' http://localhost:7990/rest/api/1.0/migration/import

++**Checks:**++

* The username and Password used is correct and has admin privilege
* Commands are run with elevated or admin access

++**Steps Followed:**++

* Created a local setup for the data center as per the below documentation [https://hub.docker.com/r/atlassian/bitbucket-server](https://hub.docker.com/r/atlassian/bitbucket-server/ "atlassian/bitbucket-server")
* Copied over the repository to the import folder using the **docker cp source_path container:destination_path**
* Tried running the curl command mentioned in the document to begin the import process but it fails with the "null for URI" 404 error. The only difference noticed is that the URL used is modified because the latter path **"imports"** structure was non-existent.

[http://localhost:7990/rest/api/1.0/migration/**import**](http://localhost:7990/rest/api/1.0/migration/import?)

[http://localhost:7990/rest/api/1.0/migration/**imports**](http://localhost:7990/rest/api/1.0/migration/imports)

**![Bitbucket_404_Error.png](https://community.atlassian.com/t5/image/serverpage/image-id/140377i82F6D61318E7C7D8/image-size/large?v=v2&px=999 "Bitbucket_404_Error.png")**


Answers:
author: Christian Glockner
body: Hi,

What error did you get when using **/imports** (with an s)?

Cheers,

Christian

Premier Support Engineer

Atlassian

comments: author: Manoj.S.J
body: Hi [@Christian Glockner](/t5/user/viewprofilepage/user-id/527595) ,

The URL is not accessible and seems like a non-existing path. I believe this is because the docker container does not have a "**imports"**folder. But can confirm that latest docker image was pulled during the execution. PFB the response when accessed via client browser for both scenarios.

Please let me know if any further details needed.

Cheers,

Manoj

![Bitbucket_404_Error_Import_1.PNG](https://community.atlassian.com/t5/image/serverpage/image-id/140421i8DA308AE02D2892D/image-size/large?v=v2&px=999 "Bitbucket_404_Error_Import_1.PNG")![Bitbucket_404_Error_Import_2.PNG](https://community.atlassian.com/t5/image/serverpage/image-id/140422iDBACC1CD0D997F09/image-size/large?v=v2&px=999 "Bitbucket_404_Error_Import_2.PNG")

![Bitbucket_URL_Not_Accessible_Imports.png](https://community.atlassian.com/t5/image/serverpage/image-id/140417iB6666AC403B937F1/image-size/large?v=v2&px=999 "Bitbucket_URL_Not_Accessible_Imports.png")


author: Christian Glockner
body: Hi,

The correct URL is /imports - the error you're getting in the browser (and HTTP 405 error) means that the URL does not support the GET method (which a browser uses to retrieve the URL). This does not mean that the URL doesn't work or is invalid.

Cheers,

Christian

Premier Support Engineer

Atlassian


author: Manoj.S.J
body: Hi [@Christian Glockner](/t5/user/viewprofilepage/user-id/527595),

Got it, checked the API definition, and have updated it accordingly. However, getting the below error even if the archive is present in the **shared/data/migration/import.**

Could you please let me know if there are any issues in the followed steps:

* Copied over the repository to the import folder using the **docker cp source_path container:destination_path**
* Tried running the below command in the same path
* curl -s -n -u "usr:pwd" -X POST -H 'Content-type: application/json' -d '{"archivePath":"2021-04-25_15-20-656_mydevopsproject1_nodejs_export.tar"}' <http://localhost:7990/rest/api/1.0/migration/imports>

![Bitbucket_Import_Invalid_Error.png](https://community.atlassian.com/t5/image/serverpage/image-id/140483i8E975055AE57BEF6/image-size/large?v=v2&px=999 "Bitbucket_Import_Invalid_Error.png")

Thanks,

Manoj


author: Manoj.S.J
body: Hi [@Christian Glockner](https://community.atlassian.com/t5/user/viewprofilepage/user-id/527595),

Could you please review the above case where the correct URL and params were used and still getting an error?

Thanks,

Manoj


Tags: bitbucket-server

data-center

server