title: How do i put headers in an api call?
body: <p>I am making an api call to </p>
  
  <p>http(s)://{hostaddress:port}/com.broadsoft.xsi-actions/v2.0/user/{userid}/services/callcenter</p>
  
  <p>I have changed the appropriate information in the URL to reflect the correct host address/port / user id. </p>
  
  <p>When that is complete, the page requests that I log on with a Username and Password. </p>
  
  <p>I can manually enter this information, and receive the XML that I need. This is not Ideal. I would rather have a form that passess in this information.</p>
  
  <p>To my understanding, this information is passed within the "headers". I have tried to look up how to do this, and even attempted using postman without much luck.  I am not sure how to do this.</p>
  
  <pre><code>function loadDoc() {
    var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
      if (this.readyState == 4 &amp;&amp; this.status == 200) {
        myFunction(this);
      }
    };
    xhttp.open("GET", "http(s)://{hostaddress:port}/com.broadsoft.xsi-actions/v2.0/user/{userid}/services/callcenter", true);
    xhttp.send();
  }
  </code></pre>
  
  <p>per w3 schools I can use setRequestHeader() which adds a label/value pair to the header to be sent. </p>
  
  <p>I have tried</p>
  
  <pre><code>function loadDoc() {
    var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
      if (this.readyState == 4 &amp;&amp; this.status == 200) {
        myFunction(this);
      }
    };
    xhttp.open("GET", "http(s)://{hostaddress:port}/com.broadsoft.xsi-actions/v2.0/user/{userid}/services/callcenter", true);
    xhttp.send();setRequestHeader(Username:myUserName,Password:myPassword);
  }
  </code></pre>
  
  <p>with no resolution. once i get this working i will set up the form and pass in  the values.</p>