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.

Creating a new Feature via API JSON Format (NodeJS)

maximilian_hansmaximilian_hans Member Posts: 3
edited October 2019 in App Store & Partners Apps
Hello everybody,

Don't know where else to post this question ,if there is a more appropriate location, please tell me =)

I'm currently trying to wrap my head around this, but I just can't get it to work. I am using NodeJS, but this is more of a general question (i guess).

I am trying to add a new feature to an existing document. For simplicity I want to declare a variable and I get back the following:
&nbsp; "moreInfoUrl" : "",<br>&nbsp; "message" : "Error in input",<br>&nbsp; "status" : 400,<br>&nbsp; "code" : 9999

The API docs read:

A feature can be added to the feature list by calling the add feature API. The API accepts as input a JSON structure containing the fields:

  • feature - A single feature definition, in the same format that is output by the get feature list API, except that there is no need to provide feature ids, node ids, or typeNames.

  • sourceMicroversion - The microversion of the document that is assumed. Any geometry ids included in the feature are interpreted in the context of this microversion.

  • rejectMicroversionSkew (optional) - If set to true, the call will refuse to make the addition if the current microversion for the document does not match the source Microversion. Otherwise, a best-effort attempt is made to re-interpret the feature addition in the context of a newer document microversion.

This is a bit vague for me - what exactly do I need? I am using the NodeJS example from github (Link) - the function I use to post is below.
When printing out an existing variable from the feature list I get the code below. How would a feature object have to look like to add a simple length variable?
  • I crossed out the parameters, that I think could be left out - is that correct?
  • Can I leave out even more?
  • What does the "type" parameter mean, is there a reference to get the different type-IDs?
  • Do I (in this case) have to send all the parameters (like for example the angleValues) eventhough I don't need them?
Copied Object:
<div>{ type: 134,<br>&nbsp; typeName: 'BTMFeature',<br>&nbsp; message:<br>&nbsp;&nbsp; { featureType: 'assignVariable',<br>&nbsp;&nbsp;&nbsp;&nbsp; featureId: 'FBDKLiWSFhxivCS_4',<br>&nbsp;&nbsp;&nbsp;&nbsp; name: '###name = #value',<br>&nbsp;&nbsp;&nbsp;&nbsp; parameters:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [ { type: 145,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <strike>typeName: 'BTMParameterEnum',</strike><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; message:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { enumName: 'VariableType',<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; value: 'LENGTH',<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; namespace: '',<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; parameterId: 'variableType',<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; hasUserCode: false,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <strike>nodeId: '1RAiTT9k/YZWmNgz'</strike> } },<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { type: 149,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <strike>typeName: 'BTMParameterString',</strike><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; message:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { value: 'height',<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; parameterId: 'name',<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; hasUserCode: false,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <strike>nodeId: '2mqEuNkuTwd4X24B'</strike> } },<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { type: 147,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<strike> typeName: 'BTMParameterQuantity'</strike>,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; message:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { units: '',<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; value: 0,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; expression: '20 mm',<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; isInteger: false,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; parameterId: 'lengthValue',<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; hasUserCode: false,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <strike>nodeId: 'oqr4JEGmAvo46VbB' </strike>} },<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { type: 147,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <strike>typeName: 'BTMParameterQuantity',</strike><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; message:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { units: '',<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; value: 0,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; expression: '0 deg',<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; isInteger: false,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; parameterId: 'angleValue',<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; hasUserCode: false,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <strike>nodeId: 'GimpgbFzb/8Z7IaC'</strike> } },<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { type: 147,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <strike>typeName: 'BTMParameterQuantity',</strike><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; message:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { units: '',<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; value: 0,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; expression: '0',<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; isInteger: false,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; parameterId: 'numberValue',<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; hasUserCode: false,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <strike>nodeId: '5mxSEl+E6b6DnP4/'</strike> } },<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { type: 147,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <strike>typeName: 'BTMParameterQuantity',</strike><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; message:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { units: '',<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; value: 0,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; expression: '0',<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; isInteger: false,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; parameterId: 'anyValue',<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; hasUserCode: false,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; nodeId: 'gHBfTGWBv2ekydiC' } },<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { type: 147,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <strike>typeName: 'BTMParameterQuantity'</strike>,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; message:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { units: '',<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; value: 0,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; expression: '20 mm',<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; isInteger: false,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; parameterId: 'value',<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; hasUserCode: false,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <strike>nodeId: 'MIPxQRFxB9slK+pV'</strike> } } ],<br>&nbsp;&nbsp;&nbsp;&nbsp; suppressed: false,<br>&nbsp;&nbsp;&nbsp;&nbsp; namespace: '',<br>&nbsp;&nbsp;&nbsp;&nbsp; subFeatures: [],<br>&nbsp;&nbsp;&nbsp;&nbsp; returnAfterSubfeatures: false,<br>&nbsp;&nbsp;&nbsp;&nbsp; suppressionState: { type: 0 },<br>&nbsp;&nbsp;&nbsp;&nbsp; hasUserCode: false,<br>&nbsp;&nbsp;&nbsp;&nbsp; <strike>nodeId: 'MhQQaUQzEjzS4GyOn'</strike> } }<br></div><div><br></div><div></div>

Function for POST request
<div><br></div><br><div><div>const&nbsp;addFeature&nbsp;=&nbsp;(documentId,&nbsp;wvm,&nbsp;wvmId,&nbsp;elementId,&nbsp;feature,conf,&nbsp;cb)&nbsp;=>&nbsp;{</div><div>&nbsp;&nbsp;var&nbsp;opts&nbsp;=&nbsp;{</div><div>&nbsp;&nbsp;&nbsp;&nbsp;d:&nbsp;documentId,</div><div>&nbsp;&nbsp;&nbsp;&nbsp;e:&nbsp;elementId,</div><div>&nbsp;&nbsp;&nbsp;&nbsp;resource:&nbsp;'partstudios',</div><div>&nbsp;&nbsp;&nbsp;&nbsp;subresource:&nbsp;'features',</div><div>&nbsp;&nbsp;&nbsp;&nbsp;feature,</div><div>&nbsp;&nbsp;&nbsp;&nbsp;sourceMicroversion:&nbsp;conf.sourceMicroversion,</div><div>&nbsp;&nbsp;&nbsp;&nbsp;serializationVersion:&nbsp;conf.serializationVersion</div><div>&nbsp;&nbsp;};</div><div>&nbsp;&nbsp;opts[wvm]&nbsp;=&nbsp;wvmId;</div><div>&nbsp;&nbsp;onshape.post(opts,&nbsp;cb);</div><div>}</div></div>






Comments

  • jakeramsleyjakeramsley Member, Moderator, Onshape Employees, Developers, csevp Posts: 660
    Here is an example post body to create a variable of:
     Type: Length
     name: xyz
     value: 1.01*in
    {
      "feature": {
        "type": 134,
        "typeName": "BTMFeature",
        "message": {
          "featureType": "assignVariable",
          "name": "",
          "parameters": [
            {
              "type": 145,
              "typeName": "BTMParameterEnum",
              "message": {
                "enumName": "VariableType",
                "value": "LENGTH",
                "parameterId": "variableType"
              }
            },
            {
              "type": 149,
              "typeName": "BTMParameterString",
              "message": {
                "value": "xyz",
                "parameterId": "name"
              }
            },
            {
              "type": 147,
              "typeName": "BTMParameterQuantity",
              "message": {
                "expression": "1.01*in",
                "parameterId": "lengthValue"
              }
            },
            {
              "type": 147,
              "typeName": "BTMParameterQuantity",
              "message": {
                "expression": "0*deg",
                "parameterId": "angleValue"
              }
            },
            {
              "type": 147,
              "typeName": "BTMParameterQuantity",
              "message": {
                "expression": "0",
                "parameterId": "numberValue"
              }
            },
            {
              "type": 147,
              "typeName": "BTMParameterQuantity",
              "message": {
                "expression": "0",
                "parameterId": "anyValue"
              }
            },
            {
              "type": 147,
              "typeName": "BTMParameterQuantity",
              "message": {
                "expression": "1.01*in",
                "parameterId": "value"
              }
            }
          ]
        }
      }
    }

    type corresponds to the parameter type (which is in plain text typeName).

    We've been working on improved ways of documenting (and generating) features through the API.  But currently I think the best way to get it is via a GET on the featurelist to get a representative feature and fill in the blanks.
    Jake Ramsley

    Director of Quality Engineering & Release Manager              onshape.com
  • maximilian_hansmaximilian_hans Member Posts: 3
    edited October 2019
    Thanks for the quick reply, Jake!

    Unfortunately I still can't get it to work. I assume that I still need document und element Ids and such stuff in my request body, right?

    I added your code to my request body but still get a 400

    here is the body I am sending through:

    <div>const&nbsp;request&nbsp;=&nbsp;{</div><div>&nbsp;&nbsp;&nbsp;&nbsp;d:&nbsp;'4f829ead28e0bf7baee955f9',</div><div>&nbsp;&nbsp;&nbsp;&nbsp;e:&nbsp;'171cae564629ef5c97accf82',</div><div>&nbsp;&nbsp;&nbsp;&nbsp;resource:&nbsp;'partstudios',</div><div>&nbsp;&nbsp;&nbsp;&nbsp;subresource:&nbsp;'features',</div><div>&nbsp;&nbsp;&nbsp;&nbsp;w:&nbsp;'e3f2c04ea2b4000581289810',</div><div>&nbsp;&nbsp;&nbsp;&nbsp;feature:</div><div>&nbsp;&nbsp;&nbsp;&nbsp;{</div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;type:&nbsp;134,</div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;typeName:&nbsp;'BTMFeature',</div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;message:</div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{</div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;featureType:&nbsp;'assignVariable',</div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;name:&nbsp;'',</div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;parameters:</div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[{</div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;type:&nbsp;145,</div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;typeName:&nbsp;'BTMParameterEnum',</div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;message:</div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{</div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;enumName:&nbsp;'VariableType',</div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;value:&nbsp;'LENGTH',</div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;parameterId:&nbsp;'variableType'</div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;},</div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{</div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;type:&nbsp;149,</div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;typeName:&nbsp;'BTMParameterString',</div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;message:&nbsp;{&nbsp;value:&nbsp;'xyz',&nbsp;parameterId:&nbsp;'name'&nbsp;}</div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;},</div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{</div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;type:&nbsp;147,</div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;typeName:&nbsp;'BTMParameterQuantity',</div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;message:&nbsp;{&nbsp;expression:&nbsp;'1.01*in',&nbsp;parameterId:&nbsp;'lengthValue'&nbsp;}</div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;},</div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{</div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;type:&nbsp;147,</div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;typeName:&nbsp;'BTMParameterQuantity',</div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;message:&nbsp;{&nbsp;expression:&nbsp;'0*deg',&nbsp;parameterId:&nbsp;'angleValue'&nbsp;}</div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;},</div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{</div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;type:&nbsp;147,</div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;typeName:&nbsp;'BTMParameterQuantity',</div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;message:&nbsp;{&nbsp;expression:&nbsp;'0',&nbsp;parameterId:&nbsp;'numberValue'&nbsp;}</div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;},</div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{</div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;type:&nbsp;147,</div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;typeName:&nbsp;'BTMParameterQuantity',</div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;message:&nbsp;{&nbsp;expression:&nbsp;'0',&nbsp;parameterId:&nbsp;'anyValue'&nbsp;}</div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;},</div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{</div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;type:&nbsp;147,</div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;typeName:&nbsp;'BTMParameterQuantity',</div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;message:&nbsp;{&nbsp;expression:&nbsp;'1.01*in',&nbsp;parameterId:&nbsp;'value'&nbsp;}</div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}]</div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</div><div>&nbsp;&nbsp;&nbsp;&nbsp;}</div><div>}</div>

  • jakeramsleyjakeramsley Member, Moderator, Onshape Employees, Developers, csevp Posts: 660
    This is the method, endpoint, headers, and body that I used.  The doc ID, workspace ID, and Element ID should be in the URL, not the body (which I am assuming the request will fill in).  
    ===== Onshape REST Request: POST https://cad.onshape.com/api/partstudios/d/32bdf212296deb7cbae78114/w/c8a1e1a3dce1ae7a15bbd034/e/2a44947bf4d2c0925ce25332/features @ 2019-10-27T23:40:26.222Z
    > User-Agent: NodeJS-Rest-Client/1.104
    > On-Nonce: TFeg3D7...truncated...owQT
    > Date: undefined
    > Cookie: on=wKCk...truncated...X2szdfQ=
    > Cookie: XSRF-TOKEN=iLF...truncated...w==
    {
      "feature": {
        "type": 134,
        "typeName": "BTMFeature",
        "message": {
          "featureType": "assignVariable",
          "name": "",
          "parameters": [
            {
              "type": 145,
              "typeName": "BTMParameterEnum",
              "message": {
                "enumName": "VariableType",
                "value": "LENGTH",
                "parameterId": "variableType"
              }
            },
            {
              "type": 149,
              "typeName": "BTMParameterString",
              "message": {
                "value": "xyz",
                "parameterId": "name"
              }
            },
            {
              "type": 147,
              "typeName": "BTMParameterQuantity",
              "message": {
                "expression": "1.01*in",
                "parameterId": "lengthValue"
              }
            },
            {
              "type": 147,
              "typeName": "BTMParameterQuantity",
              "message": {
                "expression": "0*deg",
                "parameterId": "angleValue"
              }
            },
            {
              "type": 147,
              "typeName": "BTMParameterQuantity",
              "message": {
                "expression": "0",
                "parameterId": "numberValue"
              }
            },
            {
              "type": 147,
              "typeName": "BTMParameterQuantity",
              "message": {
                "expression": "0",
                "parameterId": "anyValue"
              }
            },
            {
              "type": 147,
              "typeName": "BTMParameterQuantity",
              "message": {
                "expression": "1.01*in",
                "parameterId": "value"
              }
            }
          ]
        }
      }
    }

    Jake Ramsley

    Director of Quality Engineering & Release Manager              onshape.com
  • maximilian_hansmaximilian_hans Member Posts: 3
    I will have to look into that in more detail later, but it works when I put it into a 'body' object. thanks you for the quick help!
Sign In or Register to comment.