title: GenerateAuthenticationHeader() does not work in CRM 2013?
body: <p>We are upgrading CRM 2011 to CRM 2013. The Custom Code Validation tool flagged the method: <code>GenerateAuthenticationHeader()</code>. </p>
  
  <p>The question is what would I replace this method to be so that it works in CRM 2013. As it is giving me "undefined" when I run it. </p>
  
  <p>I have looked up many sources. One site says uses SDK REST, but it does not give the appropriate information. </p>
  
  <p>If you can kindly let me know how I can replace the method <code>GenerateAuthenticationHeader()</code> it would be much appreciated.</p>
  
  <p>The <strong>code</strong> is given below:</p>
  
  <pre><code>function GetAttributeValueFromID(sEntityName, sGUID, sAttributeName, isTextField)
  {
  
  var xml = "" +
  "&lt;?xml version=\"1.0\" encoding=\"utf-8\"?&gt;" +
  "&lt;soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"&gt;" + GenerateAuthenticationHeader() +
  "  &lt;soap:Body&gt;" +
  "    &lt;Execute xmlns=\"http://schemas.microsoft.com/crm/2007/WebServices\"&gt;" +
  "      &lt;Request xsi:type=\"RetrieveRequest\" ReturnDynamicEntities=\"false\"&gt;" +
  "        &lt;Target xsi:type=\"TargetRetrieveDynamic\"&gt;" +
  "          &lt;EntityName&gt;" + sEntityName + "&lt;/EntityName&gt;" +
  "          &lt;EntityId&gt;" + sGUID + "&lt;/EntityId&gt;" +
  "        &lt;/Target&gt;" +
  "        &lt;ColumnSet xmlns:q1=\"http://schemas.microsoft.com/crm/2006/Query\" xsi:type=\"q1:ColumnSet\"&gt;" +
  "          &lt;q1:Attributes&gt;" +
  "            &lt;q1:Attribute&gt;" + sAttributeName + "&lt;/q1:Attribute&gt;" +
  "          &lt;/q1:Attributes&gt;" +
  "        &lt;/ColumnSet&gt;" +
  "      &lt;/Request&gt;" +
  "    &lt;/Execute&gt;" +
  "  &lt;/soap:Body&gt;" +
  "&lt;/soap:Envelope&gt;" + "";
  
  var xmlHttpRequest = new ActiveXObject("Msxml2.XMLHTTP");
  
  xmlHttpRequest.Open("POST", "/mscrmservices/2007/CrmService.asmx", false);
  
  xmlHttpRequest.setRequestHeader("SOAPAction", "http://schemas.microsoft.com/crm/2007/WebServices/Execute");
  
  xmlHttpRequest.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
  
  xmlHttpRequest.setRequestHeader("Content-Length", xml.length);
  
  xmlHttpRequest.send(xml);
  
  var result = null;
  
  if (isTextField)
  {
      result = xmlHttpRequest.responseXML.selectSingleNode("//q1:" + sAttributeName).text;
  
  }
  else
  {
  
      result = xmlHttpRequest.responseXML.selectSingleNode("//q1:" + sAttributeName).getAttribute('name');
  
  }
  if (result == null)
  {
      return '';
  }
  else
      return result;
  
  }
  </code></pre>