0

I've been tinkering with codeceptjs and I wanna know if there is a way to do a sendPostRequest without a payload.

Here's my sample:

Scenario('Sample', async (I) => {
  var resp,
  args = {
  "TABLE_ID": 748,
  "STATUS" : 5
};

var reqHead = {
  'Accept'    : 'application/json',
  'User-Agent': 'Unirest Node.js'
};

var urlSamp = 'table/sample?TABLE_ID=' + args.TABLE_ID + '&STATUS=' + args.STATUS, args;

I.haveRequestHeaders(reqHead);
resp = await I.sendPostRequest(urlSamp);
resp = resp.body;
resp = JSON.stringify(resp);

I.say(resp ? resp : "Err: " + resp + " -- Msg: System may not be currently running.");
});

So, is this line correct?

resp = await I.sendPostRequest(urlSamp);

Actually, I've already done the line of code above, however it resulted into an error.

I've also tried the following below:

resp = await I.sendPostRequest(urlSamp, '');

Or...

resp = await I.sendPostRequest(urlSamp, null);

And...

resp = await I.sendPostRequest(urlSamp, {});

However, none of the above worked. Please advise. Thanks in advance.

DayIsGreen
  • 255
  • 1
  • 4
  • 16
  • I've already done this in Postman, and I was able to get the expected result. However for codecept, I'm receiving a different result. – DayIsGreen Jun 22 '18 at 07:01

1 Answers1

0

I got it.

resp = await I.sendPostRequest(urlSamp);

Above line alone is enough and actually works without the payload. My main issue was not the codeceptjs, nor the payload, but rather my system itself.

DayIsGreen
  • 255
  • 1
  • 4
  • 16