Skip to content

Git Repository Post Fork Repository.Id #587

Open
@jeffpatton1971

Description

@jeffpatton1971

We need a better example of what the payload should look like here, the documentation offers a glimpse, based on what is displayed it appears you can have either names or id's.

Name
POST https://dev.azure.com/{organization}/_apis/git/repositories?api-version=7.0

{
  "name": "forkRepository",
  "project": {
    "name": "MyFirstProject"
  },
  "parentRepository": {
    "name": "MyFirstRepo",
    "project": {
      "name": "MyFirstProject"
    }
  }
}

ID POST https://dev.azure.com/{organization}/_apis/git/repositories?sourceRef=users/heads/master&api-version=7.0

{
  "name": "forkRepositoryWithOnlySourceRef",
  "project": {
    "id": "3b046b6a-d070-4cd5-ad59-2eace5d05b90"
  },
  "parentRepository": {
    "id": "76b510af-7910-4a96-9902-b978d6226bee"
  }
}

As you can see it appears that you can have a name or an id, but based on the POST it seems like you need a sourceref param, which is not the case. Additionally working with repos in ado currently if i do not pass a repository id I receive the following error:

Invoke-RestMethod: {"$id":"1","innerException":null,"message":"The guid specified for parameter repositoryId must not be Guid.Empty.\r\nParameter name: repositoryId","typeName":"System.ArgumentException,
mscorlib","typeKey":"ArgumentException","errorCode":0,"eventId":0}

The payload in this request used a name for the forked repository akin to the first example. It appears based on the error message the payload is expected to have a RepositoryID. Now, based on this error message one would assume a ResourceId json field is required, but that is actually incorrect, instead of project.name it should be project.id. I tried several different iterations, assuming that perhaps that we cannot mix names and id's which i believe is in fact true, but also using just names failed, in fact using the first payload above complete with the POST yieled an error message that stated a projectId had to be in the URI or in the payload.

It would be incredibly helpful if the documentation included a payload schema with all possible values to be passed in, and a matrix of when to use which. Also, the lackluster error messages are frustrating and attempting to search the internet yields nearly zero useful results.

I am very open to talk about this if anyone from the documentation team would like to take the time.

Jeff

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions