lets say this is the source collection :
…“item”: [
{
“name”: “first request in collection”,
“request”: {
“method”: “POST”,
“header”: [
{
“key”: “Content-Type”,
“value”: “application/json”
}
],
“body”: {
“mode”: “raw”,
“raw”: {…}
},
“url”: {
…
},
“description”: “calling first request”
},
"response": [
…"{“newPet”:{“petName”:somia,“PetHobby”:game}}"…
]
},
{
“name”: “second request in collection”,
"request": {
“method”: “POST”,
“header”: [
{
“key”: “Content-Type”,
“value”: “application/json”
}
],
“body”: {
“mode”: “raw”,
"raw": "{“newPet”:{“petName”:somia,“PetHobby”:game}}"
},
“url”: {
…
},
“description”: “calling first request”
},
“response”:
}
]
this is the desired result: (its not the accurate format I know but only for idea explaination)
“item”
: [
{
“name”: “first request in collection”,
"event":[
{
listen:test
script:{
…pm.collectionVariables.set(newPet,data.newPet…);…
}
}
]
“request”: {
“method”: “POST”,
“header”: [
{
“key”: “Content-Type”,
“value”: “application/json”
}
],
“body”: {
“mode”: “raw”,
“raw”: {…}
},
“url”: {
…
},
“description”: “calling first request”
},
“response”: [
…"{“newPet”:{“petName”:somia,“PetHobby”:game}}"…
]
},
{
“name”: “second request in collection”,
“request”: {
“method”: “POST”,
“header”: [
{
“key”: “Content-Type”,
“value”: “application/json”
}
],
“body”: {
“mode”: “raw”,
“raw”: …{{newPet}}
},
“url”: {
…
},
“description”: “calling first request”
},
“response”:
}
]
I want to write a script which will be run on such source collections ( big amount of collections…) and will convert them to be with tests script part etc Automaticly