Share via

Azure DevOps Service - Import Requests API is returning Page Not Found Error

Ravitheja Garre 1 Reputation point
2022-01-27T07:57:59.857+00:00

I am trying to import an repository from another repo,

From Microsoft Documentation I found the API endpoint should be like:
Trying to call the API from Postman

POST https://dev.azure.com/{organization}/{project}/_apis/git/repositories/{repositoryId}/importRequests?api-version=6.0-preview.1

Request Params

{  
 "parameters": {  
 "deleteServiceEndpointAfterImportIsDone": true,  
 "gitSource": {  
 "overwrite": false,  
 "url": "https://{organisation}@dev.azure.com/{organization}/{project}/_git/{repoName}"  
 },  
 "tfvcSource": null  
 }  
}  

Source - https://learn.microsoft.com/en-us/rest/api/azure/devops/git/import-requests/create?view=azure-devops-rest-6.0

Passing Authorization in the header by converting PAT like this

"Basic " + Convert.ToBase64String(System.Text.Encoding.ASCII.GetBytes(string.Format("{0}:{1}", "", pat)));  

Via API

                        ImportRequest importrequest = new ImportRequest()  
                        {  
                            Parameters = new Parameters()  
                            {  
                                DeleteServiceEndpointAfterImportIsDone = true,  
                                GitSource = new GitSource()  
                                {  
                                    Overwrite = true,  
                                    Url = "https://{organisation}@dev.azure.com/{organization}/{project}/_git/{repoName}",  
                                },  
                                TfvcSource = null,  
                                ServiceEndpointId = "",  
                            },  
                        };  
                        var clientImportRepo = new RestClient($"{devopsURL}{project.id}/_apis/git/repositories/{reponame}/importRequests?api-version=6.0-preview.1");  
                        var createImportProjects = new RestRequest();  
                        createImportProjects.Method = Method.Post;  
                        createImportProjects.AddJsonBody(importrequest);  
                        createImportProjects.AddHeader("Authorization", "Basic " + Convert.ToBase64String(System.Text.Encoding.ASCII.GetBytes(string.Format("{0}:{1}", "", pat))));  
                        var responseImportepo = await clientImportRepo.ExecuteAsync(createImportProjects);  

I am not able to import repository. Please help me on this

Note,
PAT is having full access.
Both the repos are of Private type.
Target Repo is empty.
Able to import from Azure DevOps Portal, But i need to achieve this from API Code.

Community Center | Not monitored
0 comments No comments

1 answer

Sort by: Most helpful
  1. Monalla-MSFT 13,166 Reputation points Moderator
    2022-01-27T16:23:47.967+00:00

    @Ravitheja Garre - Thanks for reaching out.

    Devops is not currently supported here on Microsoft QnA.
    The Community Members and Engineers are actively answering questions in dedicated forums here. Please post your question in that forum:
    https://developercommunity.visualstudio.com/spaces/21/index.html
    https://azure.microsoft.com/en-in/support/devops/

    Hope this helps.

    --------------------------------------------------------------

    If the above response is helpful, please feel free to "Accept as Answer" and Upvote so it can be beneficial to the community

    Was this answer helpful?


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.