'Handle Azure Devops pipeline resource over rest api

I have an Azure DevOps pipeline with the resource section is given below

resources:
  repositories:
  - repository: test
    type: git
    name: Hackfest/template
  pipelines:
  - pipeline: Build
    source: mybuild
    branch: main
    # version:  # Latest by default
    trigger:
      branches:
        include:
        - main

I'm trying to invoke the pipeline using a rest api call. The body of the rest api call is given below

    $body='{
    "definition": {            "id": "3321"        },
     "resources": {
       "pipelines": {
         "Build": {
            "version": "20220304.15",
            "source": "mybuild"
           }
          }
        },
    "sourceBranch": "main"

}'

With the above json string I'm able to invoke the pipeline build, but it is not picking the artifacts from version 20220304.15 of the build "mybuild". Rather it is taking the latest artifact version of mybuild and starting the build.

How I should modify the above body string to pick the correct version of the "mybuild"?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source