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.

Update featurescript parameters function using API

guillauem_dguillauem_d Member Posts: 14 โœญ

Hello there! ๐Ÿ˜€

I'm having trouble updating features using the API. I created a simple cube using a FeatureScript function

Now, I'd like to update the cube size using the API.

To do this, I tried using GET /partstudios/d/{did}/w/{wid}/e/{eid}/features to see what the feature payload looks like :

  "features": [
{
"type": 134,
"typeName": "BTMFeature",
"message": {
"featureType": "myFeature",
"featureId": "F1MLG2LKDU3BAgc_0",
"name": "My Feature 1",
"parameters": [
{
"type": 147,
"typeName": "BTMParameterQuantity",
"message": {
"units": "",
"value": 0.0,
"expression": "40 mm",
"isInteger": false,
"parameterId": "myLength",
"hasUserCode": false,
"nodeId": "ZFBzFaBd6ORWRpTF"
}
}
],
"suppressed": false,
"namespace": "ea5bb9f50cf0e2008a0791914::mbf9fb36657c1ca6e3a0387dd",
"subFeatures": [],
"returnAfterSubfeatures": false,
"suppressionState": {
"type": 0
},
"hasUserCode": false,
"nodeId": "tOEqMN8K4lG+dqq7"
}
}
],

However, when I tried updating the feature by submitting the payload to both:

  • POST /partstudios/d/{did}/w/{wid}/e/{eid}/features/updates
  • POST /partstudios/d/{did}/w/{wid}/e/{eid}/features/featureid/{fid}

It didn't work. I keep encountering errors, and I believe my main issue is related to the btType fieldโ€”I'm not sure what value to use there.

Any help would be appreciated!

Answers

  • Caden_ArmstrongCaden_Armstrong Member Posts: 149 PRO

    btType is not required, but you are missing some other fields which are required:

    "serializationVersion": "string",
    "sourceMicroversion": "string"

    for custom features i think you also need libraryVersion, but I'm not 100% sure.

    It looks fine otherwise. When the request fails, usually there is an error message included with the response that can help solve theses kinds of issue.

    www.smartbenchsoftware.com --- fs.place --- Renaissance
    Custom FeatureScript and Onshape Integrated Applications
  • guillauem_dguillauem_d Member Posts: 14 โœญ

    Thank you for your king help @Caden_Armstrong !

    So I tried this payload

      -d '{
    "feature": {
    "type": 134,
    "typeName": "BTMFeature",
    "message": {
    "featureType": "myFeature",
    "featureId": "F1MLG2LKDU3BAgc_0",
    "name": "My Feature 1",
    "parameters": [
    {
    "type": 147,
    "typeName": "BTMParameterQuantity",
    "message": {
    "units": "",
    "value": 0.0,
    "expression": "40 mm",
    "isInteger": false,
    "parameterId": "myLength",
    "hasUserCode": false,
    "nodeId": "ZFBzFaBd6ORWRpTF"
    }
    }
    ],
    "suppressed": false,
    "namespace": "ea5bb9f50cf0e2008a0791914::mbf9fb36657c1ca6e3a0387dd",
    "subFeatures": [],
    "returnAfterSubfeatures": false,
    "suppressionState": {
    "type": 0
    },
    "hasUserCode": false,
    "nodeId": "tOEqMN8K4lG+dqq7"
    }
    },
    "libraryVersion": 2491,
    "serializationVersion": "1.2.7",
    "sourceMicroversion": "8ed582034102bef1fc6bca42"
    }'

    I get

    {  "moreInfoUrl": "",  "message": "La fonction ne correspond pas.",  "code": 9999,  "status": 400}
    

    The message translated in english is "The function does not match".

    I also tried removing libraryVersion with no luck ๐Ÿ˜“

Sign In or Register to comment.