Войдите в RTC с помощью oslc и rest

#rest #rational-team-concert #oslc

Вопрос:

Я новичок в Rational team concert. Пожалуйста, если кто-нибудь знает, не могли бы вы помочь мне, как войти в rational team concert с помощью oslc и rest API с таким примером кода

Спасибо.

Ответ №1:

На языке Python

 base_url = "https://jazzccm.domain:9443/ccm"
auth_url = '/authenticated/identity'
workItem_url = "https://jazzccm.domain:9443/ccm/oslc/workitems/"
session = requests.Session()
session.verify = False
session.allow_redirects = True
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)
response = session.get(workItem_url   number   '.json')
print(str(response.json()))
json_data = response.json()
 

В DXL

 // Usuall Taken from some link or some doors link
resourceURL = "https://jazzccm.domain:9443/ccm/oslc/workitems/number.json"
// create the header
HttpHeader reqHeader = null
// no body is necessary
HttpBody reqBody = null
// send request
HttpResponse resp = HttpRequest(HttpGet, resourceURL, reqBody, reqHeader)
if (resp != null)
{
    HttpHeaderEntry entry
    Buffer buff = create
    buff  = "*** STATUS ***n"
    buff  = resp.code "n"
    buff  = "*** HEADER ***n"
    // another example of the header iterator
    for entry in resp.header do
    {
        buff  = entry.key
        buff  = ":"
        buff  = entry.value
        buff  = "n"
    }
    buff  = "*** BODY ***n"
    HttpBody respBody = resp.body
    if (respBody != null)
    {
        buff  = stringOf(respBody.value) ""
    }
    else
    {
        buff  = "No body was returned."
    }
    // display the response
    displayRich("\pard " stringOf(buff))
    // remember to delete the buffer
    delete buff
    // remember to delete the response
    delete resp
}