I am using Rest api integration to send attechment frpm one servicenow instance to another sometimes its working fine but sometimes its returning status HTTP status 0 .... Can some please help me wat can be the exact problem, below is my code related to same
var answer = "";
var attachmentMsg = "";
var level = "0";
attachmentMsg = "The business rule is started";
var source = "BusinessRule";
var sycLog = new global.LogEntry();
sycLog.addLogEntry(level, attachmentMsg, source);
attachmentCount[0].toString() + ". Attachments failed to be sent: " +
attachmentCount[1].toString();
} else {
attachmentMsg = " Record had no attachments to send.";
sycLog.addLogEntry(level, attachmentMsg, source);
}
// else {
// answer = "Incident could not be sent.";
// }
answer = answer + attachmentMsg;
// Set message at top of screen with results.
//gs.addInfoMessage(answer);
function sendAttachments(sourceTable, sourceID, targetID) {
var answer = [0, 0]; //successful attachments, failed attachments
// Query for any attachments on the current record.
var tableName = current.ob_table_name;
var attachmentRec = new GlideRecord("sys_attachment");
attachmentRec.addQuery("table_sys_id", sourceID);
attachmentRec.addQuery("table_name", sourceTable);
attachmentRec.addQuery('sys_created_by', '!=', "Sycor.Ottobock.Rest.User");
attachmentRec.addQuery('u_send',"");
attachmentRec.query();
if (attachmentRec.next()) {
Issues like this are a nuisance to troubleshoot. The first thing I find very off is that you are getting a 0 response code. That would imply that you are not actually sending those messages. As you know, if there is an issue in the other instance, you would get back a code in the 400 or 500 range.
I would suggest that you check the logs on both instances to make sure that your message is actually being sent and if it is perhaps there's an issue on the receiving side such that it is not acknowledging receipt.
Hope that helps.
:{)
Helpful and Correct tags are appreciated and help others to find information faster
Hi John,
We are facing similar kind of issue, may i request you to please look into the below community post, we are unable to find the resolution.
I was rereading this after Jay's question. Getting a status of 0 usually indicates that the message was not sent. The normal HTML status codes are three digits with 200 range indicating various versions of success and 400/500 range the opposite.
You should probably make sure that you have all of your configuration options set correctly and start out with doing a basic test from there. You might also consider adding diagnostic statements to your code or follow it in debug to see if it is actually running the attempt to send, etc.
Hope that helps.
:{)
Helpful and Correct tags are appreciated and help others to find information faster