title: HTTP/1.1 401 Unauthorized in Response Headers in Load runner for GET Requests
body: <p>I am new to Load runner , Am facing am issue while play back of the script</p>
  
  <p>LR 12.50</p>
  
  <p>O.S Windows 7 SP2</p>
  
  <p>Protocol is Mobile HTTP/HTML</p>
  
  <p>Recording mode is Proxy</p>
  
  <p>Let me explain my scenario</p>
  
  <p>While executing following function:</p>
  
  <pre><code>  web_custom_request("authenticate", 
  
          "URL=https://ws-xx.xxx.com/tcs/rest/authenticate?include=user,company",     
          "Method=POST", 
          "Resource=0", 
          "RecContentType=application/json", 
          "Referer=", 
          "Snapshot=t1.inf", 
          "Mode=HTTP", 
          "EncType=application/json",
          "Body={\"password\":\"xxx\",\"username\":\"xxx\",\"version\":\"1.0.40\"}", 
          LAST);
  </code></pre>
  
  <p>For the above POST method , am getting response as below </p>
  
  <pre><code>   HTTP/1.1 200 OK\r\n
     Date: Tue, 13 Oct 2015 19:19:21 GMT\r\n
     Server: Apache-Coyote/1.1\r\n
     Content-Type: application/json\r\n
     Set-Cookie: dtCookie=DBE9311E44E5C47902702DC762030583|TXlBcHB8MQ; Path=/;
     Domain=.xxx.com\r\n    
     Connection: close\r\n
     Transfer-Encoding: chunked\r\n
  </code></pre>
  
  <p>Which is fine ,Now the second custom request is shown below </p>
  
  <pre><code>  web_custom_request("profiles", 
          "URL=https://ws-test.xxx.com/tcs/rest/profiles", 
          "Method=GET", 
          "Resource=1", 
          "RecContentType=application/json", 
          "Referer=", 
          "Snapshot=t2.inf", 
          LAST);
  </code></pre>
  
  <p>For the above GET requests  in the replay logs am getting:</p>
  
  <blockquote>
    <p>401 unauthorized error.</p>
  </blockquote>
  
  <pre><code> GET /tcs/rest/profiles HTTP/1.1\r\n
  
       User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT)\r\n
  
      Accept: */*\r\n
  
      Connection: Keep-Alive\r\n
  
       Host: ws-test.xxx.com\r\n
  
     Cookie: dtCookie=DBE9311E44E5C47902702DC762030583|TXlBcHB8MQ\r\n
  \r\n
   t=5921ms: 172-byte response headers for "https://ws-test.xxx.com/tcs/rest/profiles" (RelFrameId=1, Internal ID=2)
  
      HTTP/1.1 401 Unauthorized\r\n
  
     Date: Tue, 13 Oct 2015 19:19:22 GMT\r\n
  
     Server: Apache-Coyote/1.1\r\n
  
     Content-Type: application/json\r\n
  
      Connection: close\r\n
  
      Transfer-Encoding: chunked\r\n
     \r\n
  
  t=5922ms: 4-byte chunked response overhead for "https://ws-test.xxx.com/tcs/rest/profiles" (RelFrameId=1, Internal ID=2)
      8b\r\n
  
   t=5923ms: 139-byte chunked response body for "https://ws-test.xxx.com/tcs/rest/profiles" (RelFrameId=1, Internal ID=2)
       {"errors":[{"message":"Authentication required to access endpoint","status":"401","code":"
  
  
  
   NotAuthenticated","header":"Not Authenticated"}]}
  </code></pre>
  
  <p>I refereed <a href="http://www.sqaforums.com/showflat.php?Number=645138" rel="nofollow noreferrer">this link</a>.</p>
  
  <p>My understanding from the above custom request , login is success but the next
   subsequent requests are getting failed.</p>
  
  <p>I have used web_cleanup_cookies() function but didn't solve the issue .</p>
  
  <p>I tried to capture the Cookie ID using the below function</p>
  
  <pre><code>web_reg_save_param("COOKIE_ID",
                          "LR= Cookie: dtCookie=" ,
                          "RB= |TXlBcHB8MQ\r\n",
                          "Ord=All",
                          "RelFrameId=1",
                          "Search=All",
                          LAST);
  
  web_add_header("Cookie",lr_eval_string("{COOKIE_ID}"));
  </code></pre>
  
  <p>Now question is where to place parameter "COOKIE_ID" in my script while there is </p>
  
  <p>no value in script for COOKIE_ID?</p>
  
  <p>How to handle this issue ? Can anybody please help me .</p>