1

I'm trying to create a postman script that sends an SMS message to a phone. When I send the message I get this error:

There was an error in evaluating the test script:  JSONError: No data, empty input at 1:1 ^

This is all I have in my prereq scripts:

const dateNow = new Date();
postman.setGlobalVariable("currentDate", dateNow.toISOString())
pm.environment.set("MSISDN", "+15555555555");
pm.environment.set("%2BMSISDN", "%2B15555555555");

This is the script:

var data = pm.response.json();
pm.environment.set("msgID", data.RCSMessage.msgId);

pm.test("Status code is 202; msgId is " + data.RCSMessage.msgId, function () {
    pm.response.to.have.status(202);
});

This is the body of the script:

{
    "RCSMessage": {
        "textMessage": "SD Smoke Test Message - {{currentDate}}"
    },
    "messageContact": {
        "userContact": "{{MSISDN}}"
    }
}

The script is communicating with a bot I have setup as an environment that will send a message to a phone. I have that environment selected.

Why am I getting this error?

10
  • 2
    My guess is you have some Javascript in the Tests scripts, but you're getting no answer, or empty body in the response. Post your request and response from Postman console to your question. – pavelsaman Oct 7 '20 at 18:29
  • 1
    Error is not in prerequisites , it's in test script . Add test script to your question – PDHide Oct 8 '20 at 12:09
  • Hi, I've added the body of the script. Any help would be appreciated. Thanks! – user99201 Oct 8 '20 at 18:24
  • This is the request body, now post the rest. Request, response, and Tests script. – pavelsaman Oct 8 '20 at 18:42
  • Ok sorry I am new to postman. How would I do that? – user99201 Oct 8 '20 at 19:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.