Lets say I have a build pipeline with following definition:
parameters:
- name: "BoxNames"
displayName: 'List of box names'
type: object
default:
- name1
- name2
- name: 'id'
displayName: 'subscrption id'
type: string
default: 'xxxx'
values:
- xxxx
- yyyy
Now I am trying to queue a build for this pipeline in C# by rest api with following request body:
var requestBody = new
{
definition = new
{
id = 234,
},
project = new
{
id = xxxx
},
sourceBranch = "main",
templateParameters = new
{
BoxNames = new List<string> { "name1" },
id = "yyyy"
}
};
This is queuing the build for me but it is taking the templateParameters as default parameters, not one I am sending in the request body.
I have another pipeline with string parameters and no list values, that is picking the correct parameters by same way.
What can be the problem here?
I followed your yaml, and C# snippet, i output the
requestbodyandresponse content, it will report the errorUnable to convert from Array to String. Value: Array".you have defined
objecttype for parameterBoxNamesin yaml, but in C# script, it's string format.To fix the error, you can directly define value in request body:
The full C# script:
The devops yaml:
THe C# trigger result:
To pass mutiple strings, you can use
stringtype parameter in yaml:In the C# script, the response body as below:
The pipeline is triggered with output for each value: