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.
What's a complete API call to /partstudios/../featurescript look like?
johnsogg
Member, Developers Posts: 14 ✭
I think I have all the puzzle pieces for making an authenticated api call to evaluate a featurescript function, but I'm having trouble with cryptic error messages like "Error in input". I get the same error if I make the call via the API Explorer (using API key/secret) or from command line (using OAuth).
Here's the raw request with oauth key scrubbed (I can confirm it works using GET requests). I am hitting https://cad.onshape.com.
Here's the raw request with oauth key scrubbed (I can confirm it works using GET requests). I am hitting https://cad.onshape.com.
POST /api/partstudios/d/491cd510f26b33c86c3b1079/w/138c990145cb0318d3d0b43a/e/6c93e73cf1134e1ede7ece51/featurescript HTTP/1.1
Authorization: bearer <scrubbed>
Content-Type: application/json
Cookie: _u=websvc-c1ee691a
Host: cad.onshape.com
Connection: close
User-Agent: Paw/3.0.14 (Macintosh; OS X/10.12.1) GCDHTTPRequest
Content-Length: 167
{
"script": "scribble",
"queries": "",
"serializationVersion": "1.1.9",
"sourceMicroversion": "8ac4dc66d1e60d79bec44977",
"rejectMicroversionSkew": "false"
}
I've tried variations on the queries field (using [] and {}, for example). I'm using the feature name "scribble" (see below) and the serializationVersion and sourceMicroversion out of the results of GET /partstudios/../features.
I have a FeatureScript installed on that document (as confirmed by GET /partstudios/../features). In case there's something wrong with the FS, here it is:
The response from making the featurescript API call is:
Any ideas?
(Apologies for the formatting. The 'code' format doesn't work on render...)
I have a FeatureScript installed on that document (as confirmed by GET /partstudios/../features). In case there's something wrong with the FS, here it is:
<div></div>
<div></div>
FeatureScript 455;
import(path : "onshape/std/geometry.fs", version : "455.0");
annotation { "Feature Type Name" : "scribble" }
export const scribble = defineFeature(function(context is Context, id is Id, definition is map)
precondition
{
// Define the parameters of the feature type
}
{
return "42";
});
The response from making the featurescript API call is:
HTTP/1.1 400 Bad Request
Server: nginx
Date: Mon, 12 Dec 2016 18:23:03 GMT
Content-Type: application/json;charset=utf-8
Content-Length: 91
Connection: close
On-Version: 1.55.16903.482b9b8ea9c5
Strict-Transport-Security: max-age=31536000; includeSubDomains
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
{
"moreInfoUrl" : "",
"code" : 9999,
"message" : "Error in input",
"status" : 400
}
Any ideas?
(Apologies for the formatting. The 'code' format doesn't work on render...)
Tagged:
0
Comments
Second, you appear to be trying to call a feature, but FeatureScript evaluation calls have no persistent side-effects, so you can't use this to alter your model. You can only call these functions to extract information, though you can feed that information back into features.
Lastly, in your example you are making reference to custom featurescript code. That is not currently supported, but whatever logic you need can be supplied in the FeatureScript that you pass in. So, although your example is presumably not what you are really trying to achieve, the working example for your test case is: