我是新來加載亞軍,現在面臨時許問題,而回放腳本的HTTP/1.1 401未經授權的響應頭在獲取負載亞軍請求
LR 12.50
操作系統Windows 7 SP2
協議是移動HTTP/HTML
錄製模式是代理
讓我解釋一下我的情況
在執行以下功能:
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);
對於上述POST方法,正在逐漸響應如下
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
這很好,現在第二定製請求如下所示
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);
對於重播日誌中的上述GET請求獲得:
401未經授權的錯誤。
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"}]}
我審閱this link。
我從上面的自定義請求中瞭解到,登錄成功,但接下來的 失敗。
我已經使用web_cleanup_cookies()函數,但沒有解決問題。
我試着用下面的函數來捕獲的Cookie ID
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}"));
現在的問題是在哪裏放置參數「COOKIE_ID」在我的腳本的時候,有
在腳本COOKIE_ID沒有價值?
如何處理這個問題?任何人都可以幫助我。
@ Sivaramaraju,謝謝你的建議。使用快照視圖,我發現的authToken(「的authToken」:「eyJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUQ1MiLCJhdWQiOiJXZWJTZXJ2aWNlQVBJIiwiaWF0IjoxNDQ0Mzg1ODU2LCJleHAiOjE0NDQ 0NzIyNTYsImluZm8iOnsidXNlcklkIjoxODIsImNvbXBhbnlOdW1iZXIiOiIyMDIwMDIyIiwicHJvZmlsZUlkIjoyODF9fQ.3pP9URRrmnRHnueszw4TrzDazPjRLmhG6bRir_FftAM」)是越來越傳遞到下一個自定義的請求。即GET請求是動態的。請給我打電話,告訴我如何處理這個問題。 –
它是如何打算,作爲一個頁眉或餅乾嗎?在此基礎上按照以下步驟,如果它要在頭,關聯身份驗證令牌,然後加入web_add_header(「的authToken」,」值」);在特定請求之前。 2. \t如果它要在餅乾,關聯認證令牌,然後添加web_add_header(「曲奇」,」的authToken =值」);在特定請求之前。 – sivaramaraju
進行關聯認證令牌並使用web_add_header(「的authToken」,」 {} correlatedvalue」); – sivaramaraju