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.
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.