I have an example in python code that logs into a jazz team server and later on sends a GET request to a requirement url from doors Next. That works fine in python but I didn't manage to translate this to a working matlab script using either 'webwrite' or the 'send' method. Anyone who solved this problem succesfully?
`import urllib3
import requests
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
username ='user'
password='passw'
base_url = "https://jazzserver.com/ccm"
auth_url = '/authenticated/identity'
workItem_url = "https://jazzserver.com/rm/resources/BI_k-oRVuGVEey44LgzN4fgdKA"
session = requests.Session()
session.verify = False
session.allow_redirects = True`your text`
session.headers = {'accept':'application/json'}
session.auth = (username,password)
# authenticated user
response = session.get(base_url + auth_url)
print(str(response.headers))
print(str(response.status_code))
if 'x-com-ibm-team-repository-web-auth-msg' in response.headers and response.headers['x-com-ibm-team-repository-web-auth-msg'] == 'authrequired':
print("Not authenticated yet")
login_response = session.post(base_url + '/j_security_check', data={'j_username':username, 'j_password':password})
print(str(login_response.headers))
print(str(login_response.status_code))
if 'x-com-ibm-team-repository-web-auth-msg' in login_response.headers and login_response.headers['x-com-ibm-team-repository-web-auth-msg'] == 'authrequired':
print(str(login_response.status_code))
print("Exit HEre")
sys.exit(1)
response = session.get(base_url + auth_url)
session.headers = {'accept':'application/xml','OSCL-Core_Version':'2.0'}
response = session.get(workItem_url)
print("Response", response.content)
print(str(response.headers))
print(str(response.status_code))
`
Here is what I tried out in Matlab with some variants commented out. None of the seen code lines leads to a successful login. The last response from the server always contains 'authfailed'
`import matlab.net.*
import matlab.net.http.*
r = RequestMessage;
username ='user';
password='passw';
base_url = 'https://jazzserver.com/ccm';
auth_url = '/authenticated/identity';
workItem_url = 'https://jazzserver.com/rm/resources/BI_k-oRVuGVEey44LgzN4fgdKA';
r_header=HeaderField('accept','application/xml','OSCL-Core_Version','2.0');
options=matlab.net.http.HTTPOptions('CertificateFilename','','VerifyServerName',false);
method=RequestMethod.GET;
r = RequestMessage(method,r_header,[]);
resp = send(r,[base_url auth_url],options)
if contains(string(resp.Header),'X-com-ibm-team-repository-web-auth-msg: authrequired')
% print("Not authenticated yet")
% login_response = session.post(base_url + '/j_security_check', data={'j_username':username,'j_password':password})
%options = weboptions('RequestMethod', 'POST','HeaderFields', {'accept', 'application/json'},'MediaType','application/x-www-form-urlencoded');
%options = weboptions('MediaType','application/x-www-form-urlencoded');
data = {'j_username', username, 'j_password', password};
%login_response=webwrite([base_url '/j_security_check'],data,options)
%login_response=webwrite([base_url '/j_security_check'],data)
login_header=HeaderField('accept','application/json');
login_message = RequestMessage(RequestMethod.POST,login_header,data);
login_response=send(login_message,[base_url '/j_security_check'],options)
end
r_header=HeaderField('accept','application/xml','OSCL-Core_Version','2.0');
r_message = RequestMessage(RequestMethod.GET,r_header,[]);
resp = send(r,workItem_url,options)