Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HP QC REST API using python

I tried to connect HP QC using python to create defects and attach files, but I am not able to connect with HP QC. Here is my code:

domain='DEFAULT_773497139'
project='773497139_DEMO'
import requests

url = "https://almalm1250saastrial.saas.hpe.com/qcbin/"

querystring = {"username":"[email protected]","password":"password"}

headers = {
    'cache-control': "no-cache",
    'token': "5d33d0b7-1d04-4989-3349-3005b847ab7f"
    }

response = requests.request("POST", url, headers=headers, params=querystring)

#~ print(response.text)

print response.headers
new_header = response.headers
new_url = url+ u'rest/domains/'+domain+u'/projects/'+project
new_querystring = {
"username":"[email protected]",
"password":"password",
"domain":'DEFAULT_773497139',
"project":'773497139_DEMO'
    }
print new_url
response = requests.request("POST", new_url, headers=new_header, params=new_querystring)
print(response.text)

Now login works fine, but when try other API it asks for, I would get this message:

Authentication failed. Browser based integrations - to login append '?login-form-required=y' to the url you tried to access

If the parameter has been added, then it goes back to login page.

like image 272
Senthilnathan Avatar asked Jan 31 '17 07:01

Senthilnathan


Video Answer


1 Answers

Seems that your urls are not well builded:

base_url ='https://server.saas.hpe.com/qcbin/'
base_url + '/qcbin/rest/domains/

you will get:

..../qcbin/qcbin/...

qcbin twice

like image 100
Netwave Avatar answered Sep 19 '22 06:09

Netwave