Learning Postman, and got some trouble making DELETE call with POST call in pre-request script. Aim is to make only DELETE call without having to make POST call each time. Endpoint is swagger petstore. So, DELETE is for deleting pet by ID and POST (in pre-request) is for creating a pet with required ID. When I make a POST call separately - it works okay. When POST call is in pre-request - pet is not created. What may be wrong?
Body of separated POST call:
{
"name": "Volodya",
"photoUrls": [
"www.parrots.org/photo1"
],
"id": 202207,
"category": {
"id": 12675,
"name": "Buzza"
},
"tags": [
{
"id": 5566,
"name": "A Scary Mummy"
}
],
"status": "yes"
}
And my pre-request code:
const createPet = {
url: 'https://petstore.swagger.io/v2/pet/202207',
method: 'POST',
header: {
'Content-Type': 'application/json',
'Accept': '*/*'
},
body: {
mode: 'raw',
raw: JSON.stringify({
"name": "Volodya",
"photoUrls": [
"www.parrots.org/photo1"
],
"id": 202207,
"category": {
"id": 12675,
"name": "Buzza"
},
"tags": [
{
"id": 5566,
"name": "A Scary Mummy"
}
],
"status": "yes"
})
}
};
pm.sendRequest(createPet);
Thanks for your help.