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'
Devops-Learner
  • 451
  • 1
  • 4
  • 16

1 Answers1

0

Please try this body

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

Don't forget to change sourceVersion.

Krzysztof Madej
  • 32,704
  • 10
  • 78
  • 107
  • ` { "$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 }` – Devops-Learner May 18 '21 at 03:44
  • I have tried this as well, getting this error – Devops-Learner May 18 '21 at 03:44
  • It just stays that you have an issue with your pipeline. It is incorrect because there is no pool specified. – Krzysztof Madej May 18 '21 at 05:04
  • But if you see I have already specified the pool in the YAML file – Devops-Learner May 18 '21 at 11:53
  • 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? – Krzysztof Madej May 18 '21 at 12:20