How to assign a collection variable using portman #362
-
Hi Team i have one response in the form of array like given below, [
{
"id": 1,
"date": "2021-03-24",
"name": "h",
"group": null,
"status": "test",
"type": "test",
"start_date": "2021-03-24",
"end_date": "2021-04-27",
"product": "test",
"bok": "test"
},
{
"id": 2,
"date": "2021-03-24",
"name": "h",
"group": null,
"status": "test",
"type": "test",
"start_date": "2021-03-24",
"end_date": "2021-04-27",
"product": "test",
"bok": "test"
}
] here I need to store value of id i.e. 1 in collection variable for which I need to pass syntex like jsonData[0].id so can you please help me on that? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Typically you would do something like this in your Portman config: {
"version": 1,
"assignVariables": [
{
"openApiOperation": "POST::*",
"collectionVariables": [
{
"openApiOperationId": "get-messages",
"collectionVariables": [
{
"responseBodyProp": "[0].id",
"name": "message_id"
}
]
}
]
}
]
} Where the target is |
Beta Was this translation helpful? Give feedback.
Hi @shubhambajad
Typically you would do something like this in your Portman config:
Where the target is
"responseBodyProp": "[0].id"
which means take the 1st item from the array in the response body, and from the item take the propertyid
.