8 Replies · Latest reply on May 19, 2017 10:47 AM by Joseph Vianale

    curl api error

      We are trying to use curl to access and update Servicenow, but having issues just trying to get something simple working

       

      #!/bin/sh

      #

      curl --user username:password \

      --location-trusted \

      --header "Accept: application/json" \

      --request GET \

      https://servicenowinstance.service-now.com/incident

       

      getting the below as output

       

      cat output.txt

      <!DOCTYPE html><html lang="en" dir="ltr" class=" ltr" data-doctype="true"><head><title>ServiceNow</title><meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1"></meta><meta http-equiv="cache-control" content="public"></meta><meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no"></meta><script type="text/javascript" data-description="globals population">

              window.NOW = window.NOW || {};

              var g_loadTime = new Date();

              var lastActivity = new Date();

              var g_lang = 'en';

              var g_system_lang = 'en';

              var g_enhanced_activated = 'true';

                var g_popup_timeout = parseInt(100);

              var g_export_warn_threshold = parseInt(10000);

                var g_event_handler_ids = {};

              var g_event_handlers = [];

              var g_event_handlers_onLoad = [];

              var g_event_handlers_onSubmit = [];

              var g_event_handlers_onChange = [];

              var g_event_handlers_onCellEdit = {};

              var g_user_date_time_format = "yyyy-MM-dd HH:mm:ss";

              var g_user_date_format = "yyyy-MM-dd";

              var g_user_decimal_separator = ".";

              var g_user_grouping_separator = ",";

              var g_glide_list_separator = ", ";

              var g_tz_offset = -14400000;

                var g_tz_user_offset = true;

              var g_first_day_of_week = parseInt(1, 10);

              var g_date_picker_first_day_of_week = parseInt(0, 10);

                var g_full_calendar_edit = true;

              var g_submitted = false;

              var g_max_table_length = 80;

              var g_fontSizePreference = "";

              var g_fontSize = "10pt";

              // use to be the sys_property glide.ui.js_error_notify, hard coded for PRB603998

              var g_jsErrorNotify = "true";

              var g_cancelPreviousTransaction = true;

              var g_text_direction = "ltr";

              var g_glide_list_filter_max_length =  parseInt("0", 10);

              var g_accessibility = false;

              var g_detail_row = false;

              window.g_load_functions = [];

              window.g_render_functions = [];

              window.g_late_load_functions = [];

       

       

       

       

              var g_ck = '3933a6cadbf2f2000c78ff561d9619280e3d0618ef45cb55ebf08e549adf94d7cb7a3079';

       

       

       

       

       

       

              var g_acWaitTime = parseInt(250);

       

       

       

       

              var g_autoRequest = '';

              window.NOW.dateFormat = {shortDates: false, timeAgo: false, dateBoth: false};

              window.NOW.listTableWrap = true;

              window.NOW.compact = false;

              window.NOW.templateToggle = false;

              window.NOW.tabbed = true;

              window.NOW.permalink = true;

              window.NOW.useSimpleStorage = true;

              window.NOW.simpleStorageSynch = "579ee039db76b2000c78ff561d96192f";

              window.NOW.language =  'en';

              window.NOW.listOpenInAppTab = false;

              window.NOW.floatingScrollbars = false;

       

       

              window.NOW.user = {};

              window.NOW.user.preferences = [];

              window.NOW.user.roles = '';

              window.NOW.user.allRoles = '';

              window.NOW.user.userID = '5136503cc611227c0183e96598c4f706';

              window.NOW.user.departmentID = '221db0edc611228401760aec06c9d929';

              window.NOW.user.firstName = '';

              window.NOW.user.lastName = 'Guest';

              window.NOW.user.name = 'guest';

              </script><script data-comment="GlideUser initialization">(function() {

                       g_render_functions.push(setGlideUser);

                      function setGlideUser() {

                              if (window.g_user || !window.GlideUser)

                      return;

       

       

                      window.g_user = new GlideUser(NOW.user.name,

                                NOW.user.lastName,

                                NOW.user.firstName,

                                NOW.user.roles,

                                NOW.user.userID,

                                NOW.user.departmentID);

                      window.g_user.setRoles(NOW.user.allRoles, true);

                      }

              })();</script><link rel="shortcut icon" href="favicon.ico?v=4"></link><script>// window.performance in Chrome, Firefox, and Internet Explorer 9+ (not Safari)

                                      window.NOW.xperf = window.performance || {};

                                      if (!NOW.xperf.now) {

                                              NOW.xperf.now = function() { return new Date().getTime(); };

                                      }

                                      NOW.xperf.parseBegin = NOW.xperf.now();

                                      NOW.xperf.cssBegin = NOW.xperf.now();</script><link type="text/css" rel="stylesheet" href="/styles/css_includes_doctype.cssx?v=05-05-2017_1035&amp;c=2015-08-22_14:42:14_47f3718edb72f2000c78ff561d9619ff&amp;theme="></link><link type="text/css" rel="stylesheet" href="/styles/heisenberg/source_sans_pro.cssx?v=05-05-2017_1035&amp;c=2015-08-22_14:42:14_47f3718edb72f2000c78ff561d9619ff&amp;theme=null"></link><link type="text/css" rel="stylesheet" href="/styles/heisenberg/heisenberg_all.cssx?v=05-05-2017_1035&amp;c=2015-08-22_14:42:14_47f3718edb72f2000c78ff561d9619ff&amp;theme=null"></link><script>NOW.xperf.cssEnd = NOW.xperf.now();

                              NOW.xperf.scriptBegin = NOW.xperf.now();</script><script type="text/javascript" src="/scripts/doctype/js_includes_doctype.jsx?v=05-05-2017_1035&amp;lp=Wed_May_17_06_56_41_PDT_2017&amp;c=2_42"></script><script type="text/javascript" src="/scripts/js_includes_customer.jsx?v=05-05-2017_1035&amp;lp=Wed_May_17_06_56_41_PDT_2017&amp;c=2_42"></script><script>NOW.xperf.scriptEnd = NOW.xperf.now();

                                      NOW.xperf.parseEnd = NOW.xperf.now();

                                      $j(function() {

                                              var x = NOW.xperf;

                                              var last = x.lastDoctypeEnd - x.lastDoctypeBegin;

                                              if (window.console) {

                                                      console.log("+-- Parse times");

                                                      console.log("| CSS parse: " + (x.cssEnd - x.cssBegin));

                                                      console.log("| JS  doctype: " + (x.scriptEnd - x.scriptBegin));

                                                      console.log("| JS at end of page: " + last);

                                                      console.log("+-- All parsing: " + (x.parseEnd - x.parseBegin + last));

                                              }

       

       

                                              var ms = Math.round(x.parseEnd - x.parseBegin + last);

                                              CustomEvent.fire('page_timing', { name: 'PARS', ms: ms, win: window });

       

       

                                              if (window.performance && performance.timing) {

                                                      NOW.xperf.z = new Date().getTime();

                                                      setTimeout(function () {

                                                         var x = performance.timing.loadEventEnd - performance.timing.domContentLoadedEventStart;

                                                         CustomEvent.fire('page_timing', { name: 'DOMC', ms: x, win: window });

                                                         x = performance.timing.loadEventStart - NOW.xperf.z;

                                                         CustomEvent.fire('page_timing', { name: 'PROC', ms: x, win: window });

                                                      }, 250);  // has to be done after the loadEvent ends

                                              }

                                      })</script><script type="text/javascript" src="/scripts/doctype/js_includes_legacy.jsx?v=05-05-2017_1035&amp;lp=Wed_May_17_06_56_41_PDT_2017&amp;c=2_42"></script><script type="text/javascript" data-comment="navpage layout preferences, onfocus observation">/**

              * Every window needs to observe these events.

              */

              if (Prototype.Browser.IE && !isMSIE9) {

                      document.onfocusout = function() { CustomEvent.fireTop(GlideEvent.WINDOW_BLURRED, window); };

                      document.onfocusin = function() { CustomEvent.fireTop(GlideEvent.WINDOW_FOCUSED, window); };

              } else {

                      Event.observe(window, 'blur', function() { CustomEvent.fireTop(GlideEvent.WINDOW_BLURRED, window); });

                      Event.observe(window, 'focus', function() { CustomEvent.fireTop(GlideEvent.WINDOW_FOCUSED, window); });

              }</script><script type="text/javascript">g_swLoadTime = new StopWatch(g_loadTime);

       

       

          if (window.CustomEvent){

              CustomEvent.fireAll("ck_updated", "3933a6cadbf2f2000c78ff561d9619280e3d0618ef45cb55ebf08e549adf94d7cb7a3079");

                  CustomEvent.fireTop("navigation.complete", window);

              }

       

       

          addLoadEvent( function() {

       

       

                      if ('ontouchstart' in window ||

                                      (navigator.maxTouchPoints !== 'undefined' && navigator.maxTouchPoints > 0) ||

                                      (navigator.msMaxTouchPoints !== 'undefined' && navigator.msMaxTouchPoints > 0)) {

                              if (typeof document.body != undefined) {

                                      var bodyClass = document.body.getAttribute('class') || '';

                                      if (bodyClass.length) {

                                              bodyClass += ' ';

                                      }

                                      bodyClass += 'touch_scroll';

                                      document.body.setAttribute('class', bodyClass);

                              }

                      }

       

       

            if (typeof g_ck != 'undefined') {

              CustomEvent.observe("ck_updated", function(ck) { g_ck = ck; });

              CustomEvent.fireAll("ck_updated", "3933a6cadbf2f2000c78ff561d9619280e3d0618ef45cb55ebf08e549adf94d7cb7a3079");}try {

                    var helpico = getTopWindow().document.getElementById("help_ico");

       

       

                    if (helpico) {

                      var urlname=window.location.pathname.split("?");

                      var search_str = window.location.search;

       

       

                      // if this is a form, extract the record's sys_id...

                      var sys_id_loc = search_str.search(/sys_id=[0-9a-f]{32}/i);

                      var sys_id_str = (sys_id_loc != -1) ? search_str.substr(sys_id_loc, 39) : null;

       

       

                      // make the URL to our context help processor...

                      var url_search = "?sysparm_url=" + urlname[0];

                      if (sys_id_loc != -1)

                         url_search += "&" + sys_id_str;

       

       

                      helpico.href="context_help.do" + url_search;

                    }

                  } catch (exception) {}synchCache();

            pageLoaded();

          });

       

       

          function synchCache() {

            try {

              var w = getTopWindow();

              if (w.g_cache_message)

                w.g_cache_message.stamp("579ee039db76b2000c78ff561d96192f");

       

       

              if (w.g_cache_td)

                w.g_cache_td.stamp("e736344adbfeb2000c78ff561d961970");

            } catch(e) {}

          }</script><!--googleoff: all--><noscript>This site requires JavaScript to be enabled</noscript> <!--googleon: all--></head><body data-formName="session_timeout" ontouchend="CustomEvent.fireAll('body_clicked', event);" class="            " onclick="CustomEvent.fireAll('body_clicked', event);"><div class="outputmsg_div"><div class="outputmsg_container" style="display:none" id="output_messages"><button class="btn btn-icon close icon-cross" onclick="GlideUI.get().clearOutputMessages(this); return false;"><span class="sr-only">Close Messages"</span></button><div class="outputmsg_div"></div></div><script>addRenderEvent(function() {CustomEvent.fire('glide_optics_inspect_update_watchfield', '');});</script><span class="ui_notification" data-type="session_change" data-text="" data-attr-session_domain="global"></span></div><div class="loading-container"><h1 class="loading-message">You are not logged in, or your session has expired. Redirecting to the login page</h1><div class="loading-indicator icon-loading icon-lg"></div></div><script data-comment="loading_page redirect">setTimeout(function() {

                                      top.location.href = 'nav_to.do?uri=welcome.do';

                              }, 1500);</script><div style="border:none; visibility:hidden"><form name="sys_personalize" action="slushbucket.do" style="display:inline" method="GET"><input name="sysparm_ck" id="sysparm_ck" type="hidden" value="3933a6cadbf2f2000c78ff561d9619280e3d0618ef45cb55ebf08e549adf94d7cb7a3079"></input><input type="hidden" name="sysparm_referring_url" value="session_timeout.do"></input><input type="hidden" name="sysparm_view" value=""></input></form></div><script>(function() {

              addLateLoadEvent(throwFrameLoaded);

              // find if padding is needed

              var pad = (isMSIE6 || isMSIE7 || navigator.userAgent.indexOf('MSIE 8') != -1) ? 1 : 0;

              function throwFrameLoaded() {

                  try {

                      if (window.parent.CustomEvent) {

                          // history suggests that if we don't size it down on page load,

                          // when we check the height it will show the previous page's height

                          window.parent.CustomEvent.fire('content_frame.loaded', self.name, 10);

                          window.parent.CustomEvent.fire('content_frame.loaded', self.name, getPageHeight());

                      }

                  } catch (e) {}

              }

              function throwFrameSized() {

                  try {

                      if (window.parent.CustomEvent) {

                          // IE9/IE10: resize events will be continuously triggered when there is a difference between document.body.scrollHeight and window.frameElement.height

                          // to solve this issue, we do not fire event if the height we are going to set is the same as the height obtained after the previous fired event

                          var previousHeight = window["g_iframe_height"];

                          var pageHeight = getPageHeight();

                          if (previousHeight != pageHeight) {

                              window.parent.CustomEvent.fire('content_frame.resized', self.name, pageHeight);

                              // IE9/IE10: page height may be changed again after the above firing. So we have to call getPageHeight() to get the new height after the above event has been fired.

                              window["g_iframe_height"] = getPageHeight();

                          }

                      }

                  } catch (e) {}

              }

       

       

              function throwFrameSizedSmaller(){

                  try {

                      if (window.parent.CustomEvent) {

                          window.parent.CustomEvent.fire('content_frame.loaded', self.name, getPageHeight(true));

                      }

                  } catch (e) {}

              }

       

       

              /**

               * Simply speaking, scrollHeight and offsetHeight work differently on different browsers

               * and in and out of quirks mode. IE9 has bugs that do not report them correctly even if

               * you pick the right one, so we've built some extra controls.

               */

              function getPageHeight(resizeSmall) {

                  var popupElement, popupHeight;

                  // first, look for popups

                  var popups = $$('body > div.popup, .modal.in > .modal-dialog');

                  if (popups.length > 0) {

                      popupElement = popups[0];

                      popupHeight = popupElement.scrollHeight + popupElement.offsetTop;

                      //padding is needed or else the bottom border of the popup will be missing

                      return (document.body.scrollHeight > popupHeight ? document.body.scrollHeight : popupHeight) + pad;

                  }

                  // then, look for form elements

                  // use more specific selector to reduce browser response time

                  if ($$('body > div.section_header_content_no_scroll').length > 0) {

                      var mainContentHeight = $$('body > div.section_header_content_no_scroll')[0].scrollHeight;

       

       

                      // we use the form_title class to distinguish between UI15+ where the form title actually adds to the height

                      var header = $$('body > div.section_header_div_no_scroll.form_title');

                      var headerHeight = header.length == 0 ? 0 : header[0].scrollHeight;

                      return mainContentHeight + headerHeight;

                  }

                  // then, look for touch scroll elements *CALGARY and forward*

                  if ($$('body > .touch_scroll').length > 0)

                      return $$('body > .touch_scroll')[0].scrollHeight;

                  // then, get the normal page height

                  if (document.body.scrollHeight || document.documentElement.scrollHeight) {

                      if (!resizeSmall){

                          if(document.body.scrollHeight > document.documentElement.scrollHeight)

                              return document.body.scrollHeight;

                          else

                              return document.documentElement.scrollHeight;

                      }

                      else{

                          if(document.documentElement.scrollHeight > document.body.scrollHeight)

                              return document.body.scrollHeight;

                          else

                              return document.documentElement.scrollHeight;

                      }

                  }

                  return document.body.offsetHeight;

              }

              // start observing only after page has been loaded to avoid handling large number of resize events especially on IE 7 and IE 8

              addAfterPageLoadedEvent(function() {

                  CustomEvent.observe('frame.resized', throwFrameSized);

                  CustomEvent.observe('frame.resized.smaller', throwFrameSizedSmaller);

                  CustomEvent.observe('partial.page.reload', throwFrameLoaded); // specifically, reports and lists that cause the page to shrink

                  Event.observe(document.onresize ? document : window, "resize", throwFrameSized);

                  _frameChanged();

              });

          })();</script><span data-comments="js_includes_last_doctype" style="display:none"></span><script>NOW.xperf.lastDoctypeBegin = NOW.xperf.now();</script><script type="text/javascript" src="/scripts/doctype/js_includes_last_doctype.jsx?v=05-05-2017_1035&amp;lp=Wed_May_17_06_56_41_PDT_2017&amp;c=2_42"></script><script type="text/javascript" src="/scripts/heisenberg/heisenberg_all.jsx?v=05-05-2017_1035"></script><script type="text/javascript" src="/scripts/js_includes_list_edit_doctype.jsx?v=05-05-2017_1035&amp;lp=Wed_May_17_06_56_41_PDT_2017&amp;c=2_42"></script><script type="text/javascript" src="/scripts/transaction_scope_includes.jsx?v=05-05-2017_1035"></script><script>if ('')

                              GlideTransactionScope.setTransactionScope('');

                      if ('')

                              GlideTransactionScope.setRecordScope('');

                      if (typeof g_form != 'undefined')

                              $(g_form.getFormElement()).fire('glidescope:initialized', {gts : GlideTransactionScope});</script><span data-comments="requires" style="display:none"></span><script>NOW.xperf.lastDoctypeEnd = NOW.xperf.now();</script><span data-comments="db_context_menu_script" style="display:none"></span><script>NOW.xperf.dbContextBegin = NOW.xperf.now();</script><script>NOW.xperf.dbContextEnd = NOW.xperf.now();</script><span data-comments="db_context_menu_script" style="display:none"></span><script type="application/xml" id="glide:page_timing_div"><button style="padding:5px 5px;" type="button" title="Response time(ms): #{RESP}, Network: #{NETW}, server: #{SERV}, browser: #{REND}" class="pointerhand icon-stop-watch btn btn-icon"><span class="sr-only">Response time(ms)</span></button><span class="timing_span" style="display:none">

                        Response time(ms): #{RESP}, Network: #{NETW}, server: #{SERV}, <a class="timing_span">browser: #{REND}</a><span style="position:relative; width: 1px;"> <span style="position:absolute; bottom:0px; right:0px"><span id="page_timing_details"></span><a><div> </div></a></span></span><span class="timing_graph"><span title="Network #{NETW}ms" class="timing_network"></span><span title="Server #{SERV}ms" class="timing_server"></span><span title="Browser #{REND}ms" class="timing_browser"></span></span></span></script><script type="application/xml" id="glide:page_timing_details"><div class="timing_details">#{details}</div></script><script type="application/xml" id="glide:page_timing_detail_line"><div class="timing_detail_line #{has_children}" data-children="#{child_count}">#{HTML:name}: #{ms}

               #{children}</div></script><script type="application/xml" id="glide:page_timing_child_line"><div class="timing_detail_line timing_detail_line_child">#{HTML:name}: #{ms}</div></script><script type="text/javascript">var g_serverTime = parseInt("37") + parseInt("0");

                  var g_logClientViewRoles = "";

       

       

                              // do not do this for the navigation menu

                  if (window.name != 'gsft_nav') {

                                       addAfterPageLoadedEvent(function() {

                                               if (window.performance)

                                                      setTimeGraph();

                                               else

                                                      firePageTimer();

                                       });

                               }

       

       

                              function setTimeGraph() {

                                      if (window.performance.timing.loadEventEnd > 0)

                                              firePageTimer();

                                      else

                                              setTimeout(setTimeGraph, 300);

                               }

       

       

                              function firePageTimer() {

                                       if (window.performance && performance.timing.requestStart != performance.timing.responseStart) {

                                              var p = performance.timing;

       

       

                                              CustomEvent.fire('page_timing', { name: 'SERV', ms: p.responseEnd - p.requestStart});

                                              CustomEvent.fire('page_timing', { name: 'REND', ms: (p.loadEventEnd - p.responseEnd) });

                                              CustomEvent.fire('page_timing_network', { name: 'NETW', ms: (p.responseEnd - p.navigationStart) });

                                       } else {

                                          CustomEvent.fire('page_timing', { name: 'SERV', ms: g_serverTime });

                                              CustomEvent.fire('page_timing', { name: 'REND', startTime: g_loadTime });

                                              CustomEvent.fire('page_timing_network', { name: 'NETW', loadTime: g_loadTime });

                                       }

       

       

                                      CustomEvent.fire('page_timing_show', { show: 'false' });var o = {};

                    o.types = {};o.types['SECT'] = true;o.types['RLV2'] = true;o.types['UIOL'] = true;o.types['CSOL'] = true;

       

       

                    o.transaction_id = 'bd33a6cadbf2f2000c78ff561d961928';

                    o.table_name = '';

                    o.form_name = 'session_timeout';

                    o.view_id = 'Default view';

                    o.win = window;

                    CustomEvent.fire('page_timing_client', o);}

       

       

                  // The following line is used to set the time when we start requesting a new page

                  Event.observe(window, 'beforeunload', function() {

                                      new CookieJar().put('g_startTime', new Date().getTime());

                      CustomEvent.fireTop('request_start', document);

                  });

       

       

                  // simple pages fire this (stats.do, etc.)

                  CustomEvent.observe('simple_page.unload', function() {

                                      new CookieJar().put('g_startTime', new Date().getTime());

                  });

       

       

                  // indicate we have completed the request (used by RequestManager.js for cancel widget)

                  addLoadEvent(function() {

                      CustomEvent.fireTop("request_complete", window.location);

                  });</script><script src="scripts/doctype/z_last_include.js?v=2"></script></body><script type="text/html" id="popup_template"><div class="popup popup_form" style=""><iframe src="$src" style=""></iframe></div></script></html>