有沒有人使用過PHP的HP ALM API?將cookie和會話ID發送到HP ALM API
我正在從qcbin/API /認證餅乾/登入API
但是,當我試圖這些cookie發送到其他後續的API,它返回我httpcode 401未通過身份驗證。
此外,我正在使用qcbin /身份驗證點/身份驗證API和qcbin/api /站點會話API來獲取和維護會話。
我的代碼如下:
$ URL = 「https://myhost/qcbin/api/authentication/sign-in」; $ credentials = $ user。 ':'。 $密碼; $ headers = array(「GET /HTTP/1.1","Authorization:Basic」。base64_encode($ credentials));
curl_setopt($qc, CURLOPT_URL, $url);
curl_setopt($qc, CURLOPT_HTTPGET,1);
curl_setopt($qc, CURLOPT_HTTPHEADER, $headers);
curl_setopt($qc, CURLOPT_COOKIEJAR, $ckfile);
curl_setopt($qc, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($qc);
$response = curl_getinfo($qc);
然後我試圖得到測試集文件夾:
$ FOLDER_NAME = 「文件夾名」; $ safe_name = rawurlencode($ folder_name); $ url =「https://myhost/qcbin/rest/domains/NETWORKS_QUALITY/projects/NETWORKS/test-set-folders?query= {name ['」。 $ safe_name。 「']}」;
$qc = curl_init();
curl_setopt($qc, CURLOPT_URL, $url);
//curl_setopt($qc, CURLOPT_HTTPHEADER, $headers);
curl_setopt($qc, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($qc, CURLOPT_COOKIESESSION, TRUE);
curl_setopt($qc, CURLOPT_COOKIE,$ckfile);
curl_setopt($qc, CURLOPT_COOKIEFILE, $ckfile);
curl_setopt($qc, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($qc, CURLOPT_VERBOSE, true);
$result = curl_exec($qc);
$response = curl_getinfo($qc);
this response returns me httpcode 401 instead of 200. Please help me if anybody worked on this before.
謝謝 Biswajit耶拿
謝謝馬可。是的,我從認證API獲得200。根據您的評論,我需要在標頭中發送cookie。我試圖發送cookie中的cookie也沒有奏效。 – Biswajit
在python中,我的請求看起來像:mySession.get(url,data = xml_data,header = my_header)。大概我猜你的情況你應該檢查如何通過使用curl動作來發送標題。 –
在身份驗證過程中,因爲這是第一封沒有使用任何重要標頭的消息;)則必須使用LSSO-Cookie。 –