Welcome to the Onshape forum! Ask questions and join in the discussions about everything Onshape.
First time visiting? Here are some places to start:- Looking for a certain topic? Check out the categories filter or use Search (upper right).
- Need support? Ask a question to our Community Support category.
- Please submit support tickets for bugs but you can request improvements in the Product Feedback category.
- 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.
Assigning variables through the API Calls always results in 404 error
philip_kristoffersen
Member Posts: 5 ✭
I am trying to use the API to assign a variable value through the API.
Even when using the api exporer (https://cad.onshape.com/glassworks/explorer/#/) I always get the following error:
{
"message": "Not found.",
"moreInfoUrl": "",
"status": 404,
"code": 0
}I get get all the variables, and I have double checked that I have the correct name, and that I send valid JSON:
[{
"description":"The box depth",
"name": "BoxDepth",
"expression": "150 mm",
"type":"LENGTH"
}]
"description":"The box depth",
"name": "BoxDepth",
"expression": "150 mm",
"type":"LENGTH"
}]
If I send invalid JSON, then I get a invalid JSON so I know that I am "in" and its not an authentication error.
Here is the generated curl, but with the ids changed
curl -X 'POST' \
'https://cad.onshape.com/api/v6/variables/d/did/w/wid/e/eid/variables' \
-H 'accept: application/json;charset=UTF-8; qs=0.09' \
-H 'Content-Type: application/json;charset=UTF-8; qs=0.09' \
-H 'X-XSRF-TOKEN: 9PisF02hcnhB/D6Dy2xurQ==' \
-d '[
{
"description":"The box depth",
"name": "BoxDepth",
"expression": "150 mm",
"type":"LENGTH"
}
<span>]'</span>0
Answers
Are you an enterprise user with a different url than cad.onshape?
The 24-character string after
/documents/is the unique identifier for that document.The 24-character string after
/w/is the unique identifier for the workspace you are in.The 24-character string after
/e/is the unique identifier for the element (tab) you are in.