This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Web Inspect Enterprise REST API's 500 error

Hello everyone,

I had recently installed Web Inspect Enterprise version - 22.1, when i am trying to access the API calls it was showing 500 error. Do we need to follow any more steps to activate API's or we can use API's after the successful installation of Web Inspect Enterprise.

Thanks,

Nagesh

Parents
  • So mostly the new UIs are backed by an API. What I mean is - can you use the UI at all?

    If so, press the F12 on Chrome - capture the trace, do something on the UI that is useful - then save the trace and try some of these via API.

    If it worked on the UI, but not when you use SAME calls from the API - then something very screwy is going on.

    Now - in your example you are trying to get a token.

    You can generate tokens from the UI - so why not get a valid token then try an API call like "show me the projects". IE can you isolate the issue to "API doesnt return tokens" or is it all API is broken?

    This is how I used to get a token (this tool removed the 4 spaces for Python :-()

    def get_auth_token(session):
    url = system_url + '/WIE/REST/api/v1/auth'
    header = {
    'Content-Type': 'application/json',
    'Accept': 'application/json'
    }
    # print url
    paramsdata = {
    'username': args.user_name,
    'password': args.user_password
    }
    response = session.post(url, headers=header, data=json.dumps(paramsdata), verify=False)
    if not response.status_code == requests.codes.ok:
    print response
    sys.exit('Failed login with status {}'.format(response.status_code))
    return response.json()['data']

    and then I would get projects like:

    def get_projects(session, auth_token):
    url = system_url + '/WIE/REST/api/v1/projects?limit=10000'
    header = {
    'Content-Type': 'application/json',
    'Accept': 'application/json',
    'Authorization': 'FortifyToken={}'.format(auth_token)
    }

    # print url
    # print header
    response = session.get(url, headers=header, verify=False)
    if not response.status_code == requests.codes.ok:
    # print response
    sys.exit('Failed login with status {}'.format(response.status_code))
    return response.json()['data']

    and get info like

    auth_token = get_auth_token(session=session)
    print auth_token
    theProjects = get_projects(session=session, auth_token=auth_token)
    myProjID = -1
    for pP in theProjects:
        print "{}\t\t{}".format(pP['name'], pP['id'])
        print pP
        myProjID = pP['id']

Reply
  • So mostly the new UIs are backed by an API. What I mean is - can you use the UI at all?

    If so, press the F12 on Chrome - capture the trace, do something on the UI that is useful - then save the trace and try some of these via API.

    If it worked on the UI, but not when you use SAME calls from the API - then something very screwy is going on.

    Now - in your example you are trying to get a token.

    You can generate tokens from the UI - so why not get a valid token then try an API call like "show me the projects". IE can you isolate the issue to "API doesnt return tokens" or is it all API is broken?

    This is how I used to get a token (this tool removed the 4 spaces for Python :-()

    def get_auth_token(session):
    url = system_url + '/WIE/REST/api/v1/auth'
    header = {
    'Content-Type': 'application/json',
    'Accept': 'application/json'
    }
    # print url
    paramsdata = {
    'username': args.user_name,
    'password': args.user_password
    }
    response = session.post(url, headers=header, data=json.dumps(paramsdata), verify=False)
    if not response.status_code == requests.codes.ok:
    print response
    sys.exit('Failed login with status {}'.format(response.status_code))
    return response.json()['data']

    and then I would get projects like:

    def get_projects(session, auth_token):
    url = system_url + '/WIE/REST/api/v1/projects?limit=10000'
    header = {
    'Content-Type': 'application/json',
    'Accept': 'application/json',
    'Authorization': 'FortifyToken={}'.format(auth_token)
    }

    # print url
    # print header
    response = session.get(url, headers=header, verify=False)
    if not response.status_code == requests.codes.ok:
    # print response
    sys.exit('Failed login with status {}'.format(response.status_code))
    return response.json()['data']

    and get info like

    auth_token = get_auth_token(session=session)
    print auth_token
    theProjects = get_projects(session=session, auth_token=auth_token)
    myProjID = -1
    for pP in theProjects:
        print "{}\t\t{}".format(pP['name'], pP['id'])
        print pP
        myProjID = pP['id']

Children
No Data