1
votes

Need to create a Azure DevOps GitHub Artifact programmatically. I'm using .Net Client Libraries and tried the following code.

var artifactMetaData = new ArtifactMetadata { Alias = "ArtiAlias", InstanceReference = new BuildVersion { Id = "32q42324QQe1" } };

The Id I'm refering here is the commit Id of a Git Repo.

I could create Build Artifacts successfully using the above code but it doesn't create GitHub Artifacts.

1
+1 for asking an Azure question that has to do with programming and development. - jww
It looks like the the dotnet samples (github.com/microsoft/azure-devops-dotnet-samples/tree/master/…) don't have anything but have you tried checking the REST call through something like Fiddler to get an idea of the request body needed? (Like going through the browser with Fiddler capturing), not sure if that may show more that you can then try and find comparable SDK methods. - m00nbeam360.0
@m00nbeam360.0 Thanks for your suggestion, it led me to the correct solution. Cheers !!! - RN92

1 Answers

0
votes

Was able to check REST API call using Postman and create the ArtifactMetaData object as same as the REST API object (in request body). Then the problem was solved.

REST API Request Body,

{
  "alias": "MyRepo",
  "instanceReference": {
                "id": "r32283026ewec1c63b0842a58w2aa0a690a58265",
                "name": "r3228302",
                "sourceBranch": "feature/my-feature-branch",
                "commitMessage": "My commit message"
            }
}

C# object I created,

var artifactMetadata = new ArtifactMetadata
                    {
                        Alias = "MyRepo",
                        InstanceReference = new BuildVersion
                        {
                            Id = "r32283026ewec1c63b0842a58w2aa0a690a58265",
                            Name = "r3228302",
                            SourceBranch = "feature/my-feature-branch",
                            CommitMessage = "My commit message"
                        }
};,