0

Trying to test Rest API to trigger via postman for Azure-Devops, getting below error. tried this for bash and getting similar error. Any help or suggestion would be appreciated

Azure Devops trigger Pipeline via rest getting issue while triggering newly created pipeline

https://dev.azure.com/{{organization}}/{{project}}/_apis/build/builds?api-version=6.1-preview.6

Body

{
    "definition": {
        "id": 50
    }
}

Error

{
   {
    "$id": "1",
    "innerException": null,
    "message": "Value cannot be null.\r\nParameter name: DefaultBranch",
    "typeName": "System.ArgumentNullException, mscorlib",
    "typeKey": "ArgumentNullException",
    "errorCode": 0,
    "eventId": 0
}
}

YAML File

trigger:
- master

pool:
  vmImage: ubuntu-latest

steps:
- task: Maven@3
  inputs:
    mavenPomFile: 'pom.xml'
    mavenOptions: '-Xmx3072m'
    javaHomeOption: 'JDKVersion'
    jdkVersionOption: '1.8'
    jdkArchitectureOption: 'x64'
    publishJUnitResults: true
    testResultsFiles: '**/surefire-reports/TEST-*.xml'
    goals: 'package'

1 Answer 1

0

Please try this body

{
    "templateParameters": { "doReleaseBuild": "True" }, 
    "definition": {
        "id": 50
    },
    "sourceBranch": "refs/heads/main",
    "sourceVersion": "d265f01aeb4e677a25725f44f20ceb3ff1d7d767"
}

Don't forget to change sourceVersion.

Sign up to request clarification or add additional context in comments.

5 Comments

` { "$id": "1", "customProperties": { "ValidationResults": [ { "result": "error", "message": "No pool was specified." } ] }, "innerException": null, "message": "Could not queue the build because there were validation errors or warnings.", "typeName": "Microsoft.TeamFoundation.Build.WebApi.BuildRequestValidationFailedException, Microsoft.TeamFoundation.Build2.WebApi", "typeKey": "BuildRequestValidationFailedException", "errorCode": 0, "eventId": 3000 }`
I have tried this as well, getting this error
It just stays that you have an issue with your pipeline. It is incorrect because there is no pool specified.
But if you see I have already specified the pool in the YAML file
Well, I see your yaml. And you don't have to define pool in the body via REST call. Can you try to validate your YAML from the portal?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.