var
options = {
host:
'mail.zoho.com',
path:
'/api/accounts/4551522000000XXXXXX/messages',
header: {
'Authorization'
:
'Zoho-authtoken 9cb09784703XXXXXXXXXXXXXXXXXXXX',
'Content-Type'
:
'application/json'
},
method:
'POST'
};
var
dd = {
"subject"
:
"Email - Always and Forever",
"content"
:
"Email can never be dead. The most neutral and effective way, that can be used for one to many and two way communication."
};
reqt =
http.
request(
options,
function(
resp) {
console.
log(
'STATUS: ' +
resp.
statusCode);
console.
log(
'HEADERS: ' +
JSON.
stringify(
resp.
headers));
resp.
setEncoding(
'utf8');
var
body =
'';
resp.
on(
'data',
function (
chunk) {
console.
log(
'BODY: ' +
chunk);
body +=
chunk;
});
resp.
on(
'end', ()
=> {
postResponse(
res,
200,
false,
body);
});
resp.
on(
'error', (
err)
=> {
postResponse(
res,
400,
true, {
"m"
:
"m2"
,
"error"
:
err});
});
});
reqt.
on(
'error', (
err)
=> {
postResponse(
res,
400,
true, {
"m"
:
"m1"
,
"error"
:
err});
})
reqt.
write(
querystring.
stringify(
dd));
reqt.
end();
I am getting 301 permanently removed when calling this api. Whats wrong and how to implement it?