My question: How can I check in a pre-request script if the request body has any content?
I’ve already tried:
if (!pm.request.body.isEmpty) {
if (!pm.request.body.disabled) {
… but it doesnt work for me. The if-statement is always true.
My question: How can I check in a pre-request script if the request body has any content?
I’ve already tried:
if (!pm.request.body.isEmpty) {
if (!pm.request.body.disabled) {
… but it doesnt work for me. The if-statement is always true.
Hi @svenpeng
Try;
if (!pm.request.body.raw){
console.log('NULL');
console.log(pm.request.body);
}else{
console.log('NOT NULL');
console.log(pm.request.body);
}
Example output;