Support

 View Only
Expand all | Collapse all

APIServerException: 500 Server Error when attempting to use Python REST API (py-jama-rest-client)

  • 1.  APIServerException: 500 Server Error when attempting to use Python REST API (py-jama-rest-client)

    Posted 05-16-2022 14:01
    Hi All, 

    I am running into an error when trying to get all the projects in my Jama instance. I am using the code example shared for the Python REST API (py-jama-rest-client) in GitHub (GitHub - jamasoftware-ps/py-jama-rest-client: A client for the Jama Connect REST API implemented in python.). 

    Has anyone ran into a similar issue and found a solution? Any alternatives or suggestions? Thank you in advance!

    Code: 
    from py_jama_rest_client.client import JamaClient

    # Setup your Jama instance url, username, and password.
    # You may use environment variables, or enter your information directly.
    # Reminder: Follow your companies security policies for storing passwords.
    jama_url = 'JAMA_API_URL'
    jama_api_username = 'JAMA_API_USERNAME'
    jama_api_password = 'JAMA_API_PASSWORD'

    # Create the JamaClient
    jama_client = JamaClient(host_domain=jama_url, credentials=(jama_api_username, jama_api_password))

    Error Message:
    500 Server error.
    Traceback (most recent call last):

    File "C:\Users\yolivo\Desktop\test.py", line 20, in <module>
    project_list = jama_client.get_projects()

    File "C:\Users\yolivo\Anaconda3\lib\site-packages\py_jama_rest_client\client.py", line 142, in get_projects
    project_data = self.__get_all(resource_path, allowed_results_per_page=allowed_results_per_page)

    File "C:\Users\yolivo\Anaconda3\lib\site-packages\py_jama_rest_client\client.py", line 1400, in __get_all
    page_response = self.__get_page(resource, start_index, params=params, **kwargs)

    File "C:\Users\yolivo\Anaconda3\lib\site-packages\py_jama_rest_client\client.py", line 1429, in __get_page
    JamaClient.__handle_response_status(response)

    File "C:\Users\yolivo\Anaconda3\lib\site-packages\py_jama_rest_client\client.py", line 1490, in __handle_response_status
    raise APIServerException("{} Server Error.".format(status),

    APIServerException: 500 Server Error.

    ------------------------------
    Yori Olivo
    Stryker
    ------------------------------


  • 2.  RE: APIServerException: 500 Server Error when attempting to use Python REST API (py-jama-rest-client)

    Posted 05-20-2022 14:49
    Hi Yori, 

    How many items in total are attempting to be fetched at once when the error occurs?

    ------------------------------
    Carly Rossi // she/her
    Community Manager // Jama Software
    Portland, OR
    ------------------------------



  • 3.  RE: APIServerException: 500 Server Error when attempting to use Python REST API (py-jama-rest-client)

    Posted 05-23-2022 05:30
    Hi Carly, 

    Thank you for responding. I am using the .get_projects() options to get a list of project in Jama (less than 5 projects). I also attempted to use .get_item('GIDXXX') and get the same error. 

    Best, 

    Yori

    ------------------------------
    Yori Olivo
    Stryker
    ------------------------------



  • 4.  RE: APIServerException: 500 Server Error when attempting to use Python REST API (py-jama-rest-client)

    Posted 05-23-2022 11:00
    Thanks, Yori --- how many items are there (between all the projects) in total?

    ------------------------------
    Carly Rossi // she/her
    Community Manager // Jama Software
    Portland, OR
    ------------------------------



  • 5.  RE: APIServerException: 500 Server Error when attempting to use Python REST API (py-jama-rest-client)

    Posted 05-23-2022 11:19
    ~4,000 items.

    ------------------------------
    Yori Olivo
    Stryker
    ------------------------------



  • 6.  RE: APIServerException: 500 Server Error when attempting to use Python REST API (py-jama-rest-client)

    Posted 29 days ago
    Edited by Carly Rossi 28 days ago
    Thanks!

    If you remove the trailing slash from the URL in the client script, does that resolve the error? You'll also want to make sure that the username and password set in the script are the ones you use for your Jama instance, and *not* the client ID and the secret set (in API Credentials).


    ------------------------------
    Carly Rossi // she/her
    Community Manager // Jama Software
    Portland, OR
    ------------------------------



  • 7.  RE: APIServerException: 500 Server Error when attempting to use Python REST API (py-jama-rest-client)

    Posted 28 days ago
    Awesome, thank you Carly! This helped me solve my issue. 

    I removed the trailing slash and ended up setting API credential using OAuth. I followed the instructions here and it worked fine: https://einride.jamacloud.com/help/ah/en/setting-up-your-work-environment/editing-and-managing-your-profile/set-api-credentials.html

    ------------------------------
    Yori Olivo
    Stryker
    ------------------------------



  • 8.  RE: APIServerException: 500 Server Error when attempting to use Python REST API (py-jama-rest-client)

    Posted 28 days ago
    Awesome, Yori, I'm so glad that helped -- thanks for following up!

    ------------------------------
    Carly Rossi // she/her
    Community Manager // Jama Software
    Portland, OR
    ------------------------------



  • 9.  RE: APIServerException: 500 Server Error when attempting to use Python REST API (py-jama-rest-client)

    Posted 24 days ago
    It remains a problem that the API server failed (status 500), so @Carly Rossi please ​​submit a ticket against the API server project.

    ------------------------------
    Chris Eich
    Xenter Inc.
    SLC, UT
    ------------------------------



  • 10.  RE: APIServerException: 500 Server Error when attempting to use Python REST API (py-jama-rest-client)

    Posted 3 days ago
    Hi Chris, 

    Removing the trailing slash should prevent status 500 errors from occurring, or resolving that error when it does. If it's persisting beyond that, submitting a detailed ticket to Support directly would be the best bet.

    ------------------------------
    Carly Rossi // she/her
    Community Manager // Jama Software
    Portland, OR
    ------------------------------



  • 11.  RE: APIServerException: 500 Server Error when attempting to use Python REST API (py-jama-rest-client)

    Posted 2 days ago
    Hi Yori,
    I had some problems with the py-jama-rest-client as well.  I ended up using request in the Python library to resolve the problem.  Sample code for creating a new item:

    import
    requests
    post_url = url+ 'rest/v1/items/'
    response = requests.post(post_url,json=new_data,auth=(username, secret),headers=headers)
    json_resp=response.json()

    Hope this helps



    ------------------------------
    Martha Fiske
    Lucid Motors
    ------------------------------