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.

Assigning variables through the API Calls always results in 404 error

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",

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",


  • Matt_ShieldsMatt_Shields Member Posts: 142 EDU
    What endpoint are you using?  I think you can only do POST requests to the variables endopoint for Variable Studios.  
  • caden_armstrongcaden_armstrong Member, User Group Leader Posts: 119 PRO
    When you make the call, are you replacing the did/wid/eid with the actual ids of your variable studio?
    Are you an enterprise user with a different url than cad.onshape? 
    Software Development Lead - CADSharp.com - [email protected]
    We specialize in custom FeatureScripts, and Onshape integrated applications
    Monarch - Renaissance
  • philip_kristoffersenphilip_kristoffersen Member Posts: 5
    I found the problem here. The EID (which I still don't know what is) is different if you are looking at designing a part and if you are in variable studio. By changing the EID to be the one for variable studio I am able to set variables.
  • Matt_ShieldsMatt_Shields Member Posts: 142 EDU
    Correct.  When you are in an Onshape document, the URL will look something like:


    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.
Sign In or Register to comment.