python 401 error

lv_sshuai
lv_sshuai Member Posts: 4 ✭

When I log in to the URL https://cad.onshape.com/glassworks/explorer/#/PartStudio and authorize through the API, I find that GET operations work, but POST operations result in an error. Using Python, I can access features through GET, but when I try to access FeatureScript with POST, I encounter a 401 Client Error: Unauthorized for the URL https://cad.onshape.com/api/v6/partstudios/d/03e46cf3083711bca0f5bf60/w/b5fbff3a6045ce47fe72985b/e/6b42da54504ca039e842ce02/featurescript.
This is my file link: https://cad.onshape.com/documents/03e46cf3083711bca0f5bf60/w/b5fbff3a6045ce47fe72985b/e/6b42da54504ca039e842ce02. I have opened file sharing.

I copied the code for my entire project from this place: https://github.com/ChrisWu1997/onshape-cad-parser
but when I run process.py --test, I always encounter a 401 error. I checked and found that I can run the get_features file, but an error occurs when running featurelistparser. Can you help me solve this problem?

Answers

  • Paul_J_Premakumar
    Paul_J_Premakumar Member, Onshape Employees Posts: 238 image
    Hi!

     When you say " authorize through the API" do you mean use the API keys? If so you may want to ensure you created the keys with the "Application can write to your documents" enabled. POST requests which modify the document, need write permission on the document. 


  • lv_sshuai
    lv_sshuai Member Posts: 4 ✭
    Hi!
    When I created the API, I chose this option, oauth2write.All the above operations were performed while connected to a remote server. Is this related? Can API access only be achieved when working locally?