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.

Issue while using "globaltreenodes" API for trash in Onshape storage

Actually I was trying to use the native onshape APIs for trash but for some reason I am getting the "forbidden" error.

I am using these 3 APIs.

https://cad.onshape.com/api/globaltreenodes/restore
This works fine.

But I am getting 403 (Forbidden) for these 2 requests, I am using the same type of auth and respective json body.
https://cad.onshape.com/api/globaltreenodes/emptyTrash
https://cad.onshape.com/api/globaltreenodes/delete

For eg, for /delete - 
My body is -
<div>{</div><div>&nbsp;&nbsp;&nbsp;&nbsp;"itemsToMove":&nbsp;[</div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{</div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"resourceType":&nbsp;"folder",</div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"id":&nbsp;"087c742dd84d5eae353d6e2a"</div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</div><div>&nbsp;&nbsp;&nbsp;&nbsp;]</div><div>}</div>

Can anyone please help here, what could be wrong ?



Answers

  • caden_armstrong2caden_armstrong2 Member, User Group Leader Posts: 127 ✭✭✭
    edited September 2023
    You can delete folders with the /magic/4 endpoint:

    POST https://cad.onshape.com/api/globaltreenodes/magic/4
    {
        "itemsToMove":[
            {"id":"b7c7aeee4c2b2bacf255d71f","resourceType":"folder"}
        ]
    }

    Just make sure that your OAuth application in the dev portal has permission to delete


  • aman_singh005aman_singh005 Member Posts: 11
    Thanks for the response.

    So, this "delete" is for the trash, right ? I mean it will delete the folder forever ?
    I guess it's a normal delete.

    Also, can you please let me know if there is a way to empty the trash using any APIs ?

    Or if you can provide me some documentation, that would be great help.
  • caden_armstrong2caden_armstrong2 Member, User Group Leader Posts: 127 ✭✭✭
    As far as I know, there's no way to empty the trash via the API.
    The /delete api for removing from trash seems to not be a publicly accessible API.

    These APIs don't exactly have documentation, and are likely not officially supported. 
    Onshape has more than a few APIs that are not publicly accessible.
  • aman_singh005aman_singh005 Member Posts: 11
    Okay, I am getting your point.

    So, is there any alternative or anything you might help here ?
Sign In or Register to comment.