Welcome to the Onshape forum! Ask questions and join in the discussions about everything Onshape.

First time visiting? Here are some places to start:
  1. Looking for a certain topic? Check out the categories filter or use Search (upper right).
  2. Need support? Ask a question to our Community Support category.
  3. Please submit support tickets for bugs but you can request improvements in the Product Feedback category.
  4. Be respectful, on topic and if you see a problem, Flag it.

If you would like to contact our Community Manager personally, feel free to send a private message or an email.

Python API: 401 Unauthorised when include_mate_connectors set to true in get_assembly_def arguments

anthony_cheunganthony_cheung Member Posts: 6
edited May 2019 in General

^ I've been using the above code to get the assembly definition but when I set include_mate_connectors in get_assembly_definition call I get a 401 error.
However it works fine if I remove them.

Wondering if anyone could help diagnose this issue. Thanks.


  • Ethan_KEthan_K Member, Onshape Employees Posts: 51
    Thank you for trying out the experimental python client! I'm happy to help you here, but FYI, I posted an issue against the repo itself to track this issue here: https://github.com/onshape-public/python-client/issues/4
  • Ethan_KEthan_K Member, Onshape Employees Posts: 51
    edited May 2019
    Just fixed this -- see here: https://github.com/onshape-public/onshape-clients/blob/master/python/test/test_assemblies_api.py One thing to note is that the inlcude_mate_connectors only actually does everything if you also set the include_features flag.
  • anthony_cheunganthony_cheung Member Posts: 6
    Apologies I was inaccurate. It was actually if you put in any kwargs. Thanks for the quick fix!
  • anthony_cheunganthony_cheung Member Posts: 6
    edited May 2019

    installed onshape-client with pip install (confirmed on 0.0.24)
    cloned the onshape-clients repo

    pipenv shell in onshape-clients/python then ran my get assembly definition code
    and now I'm getting Error 111 Connection Refused.

    tried without pipenv --> same error

    Let me know if I did something wrong, thanks.
  • Ethan_KEthan_K Member, Onshape Employees Posts: 51
    edited May 2019
    Hmm... what did you plugin for your baseurl in your credentials file? It should be https://cad.onshape.com (without the /api). Specifically, your creds file should look like (of course with your own credentials plugged in): 
    prod:  base_url: "https://cad.onshape.com"
    access_key: XXXXXXXXXXXXXX default_stack: prod
  • anthony_cheunganthony_cheung Member Posts: 6
    edited May 2019
    In my code I added the second line:
    configuration = onshape_client.Configuration()
    configuration.host = "http://cad.onshape.com"

    Fixes the issue 111 error because the URL is correct now. Default configuration.host is set to localhost in configuration.py.

    However, now I get a returned None from my API call. Any ideas?

    I copied the URL the program uses and it works in my browser.
  • Ethan_KEthan_K Member, Onshape Employees Posts: 51
    That is because some of our APIs still don't have typing information migrated to openAPI. You'll need to add the keyword argument 

  • anthony_cheunganthony_cheung Member Posts: 6
    @ethan_keller769 thanks for all the help 
Sign In or Register to comment.