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.
Add PartStudio Feature using Onshape Java client --> Error processing json
Hello Community,
I try to write an app to generate a model by adding FeatureScript-Features to a PartStudio.
I am able to add a feature to a PartStudio using the method at Glassworks. However I get an exception (com.onshape.api.exceptions.OnshapeException: Error processing json) trying to do the same via Java client.
I minimised the program to the essential part to be easily tested.
Any help identifying the cause of the problem is appreciated.
BR: Eduard
Best Answer
-
So, it looks like the problem is the outdated logic for building URI in the Java client (class BaseClient, method buildURI). In the line 701 "/api" should be replaced by "/api/v12".
I suppose, Java client is not supported, isn't it?
0
Answers
-
So, it looks like the problem is the outdated logic for building URI in the Java client (class BaseClient, method buildURI). In the line 701 "/api" should be replaced by "/api/v12".
I suppose, Java client is not supported, isn't it?
0 -
/api/ or /api/v12 both work.
Specifying the specific version can give you a different input/output format.
What body/json are you sending to the API? That is most likely the problem. Getting the body right with adding features can be tricky, especially depending on the feature.www.smartbenchsoftware.com --- Renaissance --- Kestrel -- SmartLink
Experts in Onshape Automation - Custom Features and Integrated Applications0 -
Hi Caden, thank you for your response!
Here is the content of my log in both cases:Fail
Success
Request
Jul 24, 2025 5:40:58 PM org.glassfish.jersey.logging.LoggingInterceptor log
INFO: 1 * Sending client request on thread main
1 > POST https://cad.onshape.com/api/partstudios/d/98735c7f8c1ac21f8d942291/w/dab35e734e010433bf2bc7e5/e/432c59f2fec966f4e76cffe9/features
1 > Accept: application/vnd.onshape.v1+json,application/json
1 > Accept-Encoding: gzip
1 > Authorization: On 3J3VMPpWAquCrdX5Zst6QAsL:HmacSHA256:mpu1TrK2Wq4hmyYPve6zQ87cZEh68QWRfBSBrxTkXRk=
1 > Content-Type: application/json
1 > Date: Thu, 24 Jul 2025 15:40:56 GMT
1 > On-Nonce: 90gepkwpy472dv1zrfjwlmvy4
{"feature":{"btType":"BTMFeature-134","namespace":"ebbaf3d48f5f119e6cc4bc003::m2a99f6dea331231071704f73","featureType":"StepModule","name":"Step Module","parameters":[{"btType":"BTMParameterQuantity-147","isInteger":false,"value":0,"units":"","expression":"25 mm","nodeId":"rX/EhwuhJ11tiFvp","parameterId":"d"},{"btType":"BTMParameterQuantity-147","isInteger":false,"value":0,"units":"","expression":"100 mm","nodeId":"AF8KX0LloRo1bek2p1yyDiex","parameterId":"l"},{"btType":"BTMParameterBoolean-144","value":true,"nodeId":"+jv75zh1sJThjznr","parameterId":"keyway"},{"btType":"BTMParameterQuantity-147","isInteger":false,"value":0,"units":"","expression":"0 mm","nodeId":"zkISxynBTId0d2Lkji9uu9V+","parameterId":"chamferRight"},{"btType":"BTMParameterQuantity-147","isInteger":false,"value":0,"units":"","expression":"1 mm","nodeId":"uWD8o/Rg8MsHozhTJkppXq17","parameterId":"chamferLeft"},{"btType":"BTMParameterQuantity-147","isInteger":false,"value":0,"units":"","expression":"0 mm","nodeId":"zS+j4Pk1x2Yj2aWkDXge6LA0","parameterId":"offset"}]},"serializationVersion":"1.2.11","sourceMicroversion":"a0c6cda7b0cd24a906629703","rejectMicroversionSkew":false}
Jul 24, 2025 5:48:50 PM org.glassfish.jersey.logging.LoggingInterceptor log
INFO: 1 * Sending client request on thread main
1 > POST https://cad.onshape.com/api/v12/partstudios/d/98735c7f8c1ac21f8d942291/w/dab35e734e010433bf2bc7e5/e/432c59f2fec966f4e76cffe9/features
1 > Accept: application/vnd.onshape.v1+json,application/json
1 > Accept-Encoding: gzip
1 > Authorization: On 3J3VMPpWAquCrdX5Zst6QAsL:HmacSHA256:sPXg3wgkbn/XX+GqXirydHS3bbpRUzYK6EE5aqZEsRs=
1 > Content-Type: application/json
1 > Date: Thu, 24 Jul 2025 15:48:48 GMT
1 > On-Nonce: jler9vxjder1r1z4jt9xpkygm
{"feature":{"btType":"BTMFeature-134","namespace":"ebbaf3d48f5f119e6cc4bc003::m2a99f6dea331231071704f73","featureType":"StepModule","name":"Step Module","parameters":[{"btType":"BTMParameterQuantity-147","isInteger":false,"value":0,"units":"","expression":"25 mm","nodeId":"rX/EhwuhJ11tiFvp","parameterId":"d"},{"btType":"BTMParameterQuantity-147","isInteger":false,"value":0,"units":"","expression":"100 mm","nodeId":"AF8KX0LloRo1bek2p1yyDiex","parameterId":"l"},{"btType":"BTMParameterBoolean-144","value":true,"nodeId":"+jv75zh1sJThjznr","parameterId":"keyway"},{"btType":"BTMParameterQuantity-147","isInteger":false,"value":0,"units":"","expression":"0 mm","nodeId":"zkISxynBTId0d2Lkji9uu9V+","parameterId":"chamferRight"},{"btType":"BTMParameterQuantity-147","isInteger":false,"value":0,"units":"","expression":"1 mm","nodeId":"uWD8o/Rg8MsHozhTJkppXq17","parameterId":"chamferLeft"},{"btType":"BTMParameterQuantity-147","isInteger":false,"value":0,"units":"","expression":"0 mm","nodeId":"zS+j4Pk1x2Yj2aWkDXge6LA0","parameterId":"offset"}]},"serializationVersion":"1.2.11","sourceMicroversion":"a0c6cda7b0cd24a906629703","rejectMicroversionSkew":false}
Response
Jul 24, 2025 5:40:58 PM org.glassfish.jersey.logging.LoggingInterceptor log
INFO: 1 * Client response received on thread main
1 < 400
1 < Connection: keep-alive
1 < Content-Length: 95
1 < Content-Security-Policy: frame-ancestors 'self' *.onshape.com *.dev.onshape.com *.creo.ptc.com https://onshapesandbox4.thoughtindustries.com https://localhost.dev.onshape.com:8000; font-src 'self' data: https://*; img-src 'self' data: blob: https://*; style-src 'self' 'unsafe-inline' data: https://*; object-src 'self'; base-uri 'self'; worker-src 'self' blob:; script-src 'self' 'unsafe-inline' 'unsafe-eval'; script-src-elem 'self' 'unsafe-inline' https://code.jquery.com/jquery-3.5.1.min.js https://looker-custom-viz-a.lookercdn.com/master/v1_common.js https://*.awswaf.com https://ajax.googleapis.com https://cdn.mouseflow.com https://cdnjs.cloudflare.com https://www.datadoghq-browser-agent.com https://img04.en25.com https://js.stripe.com https://www.googletagmanager.com https://js.driftt.com https://cdn.taboola.com https://trc.taboola.com https://www.recaptcha.net https://www.gstatic.com https://www.google.com/jsapi https://widget.usersnap.com https://resources.usersnap.com https://www.google-analytics.com https://fast.wistia.net https://fast.wistia.com https://www.youtube.com https://static-a.lookercdn.com https://static-b.lookercdn.com https://cdn.trackjs.com https://maps.googleapis.com; script-src-attr 'self' 'unsafe-inline'; report-uri https://cad.onshape.com/api/csp
1 < Content-Type: application/json
1 < Date: Thu, 24 Jul 2025 15:40:58 GMT
1 < on-version: 1.201.59946.273cf652a478
1 < Strict-Transport-Security: max-age=31536000; includeSubDomains
1 < traceparent: 00-00000000000000007c318e0e5b03a672-7c318e0e5b03a672-00,00-0000000000000000eb7ef6ea587ef5d8-eb7ef6ea587ef5d8-00
1 < x-api-version: v1
1 < X-Content-Type-Options: nosniff
1 < X-Rate-Limit-Remaining: 500
1 < x-request-id: 6674867ff29226e1e503d9e83678f237
1 < X-XSS-Protection: 1; mode=block
{
"moreInfoUrl" : "",
"message" : "Error processing json",
"status" : 400,
"code" : 0
}
Jul 24, 2025 5:48:52 PM org.glassfish.jersey.logging.LoggingInterceptor log
INFO: 1 * Client response received on thread main
1 < 200
1 < Connection: keep-alive
1 < Content-Encoding: gzip
1 < Content-Security-Policy: frame-ancestors 'self' *.onshape.com *.dev.onshape.com *.creo.ptc.com https://onshapesandbox4.thoughtindustries.com https://localhost.dev.onshape.com:8000; font-src 'self' data: https://*; img-src 'self' data: blob: https://*; style-src 'self' 'unsafe-inline' data: https://*; object-src 'self'; base-uri 'self'; worker-src 'self' blob:; script-src 'self' 'unsafe-inline' 'unsafe-eval'; script-src-elem 'self' 'unsafe-inline' https://code.jquery.com/jquery-3.5.1.min.js https://looker-custom-viz-a.lookercdn.com/master/v1_common.js https://*.awswaf.com https://ajax.googleapis.com https://cdn.mouseflow.com https://cdnjs.cloudflare.com https://www.datadoghq-browser-agent.com https://img04.en25.com https://js.stripe.com https://www.googletagmanager.com https://js.driftt.com https://cdn.taboola.com https://trc.taboola.com https://www.recaptcha.net https://www.gstatic.com https://www.google.com/jsapi https://widget.usersnap.com https://resources.usersnap.com https://www.google-analytics.com https://fast.wistia.net https://fast.wistia.com https://www.youtube.com https://static-a.lookercdn.com https://static-b.lookercdn.com https://cdn.trackjs.com https://maps.googleapis.com; script-src-attr 'self' 'unsafe-inline'; report-uri https://cad.onshape.com/api/csp
1 < Content-Security-Policy-Report-Only: frame-src 'self' https://*.dev.graebert.com https://*.onshape.io https://td.doubleclick.net https://js.stripe.com https://www.recaptcha.net https://*.onshape.com https://fast.wistia.net https://fast.wistia.com https://www.youtube.com https://js.driftt.com https://www.googletagmanager.com; report-uri https://cad.onshape.com/api/csp
1 < Content-Type: application/json;charset=utf-8
1 < Date: Thu, 24 Jul 2025 15:48:52 GMT
1 < On-Version: 1.201.59946.273cf652a478
1 < Set-Cookie: _u=webservice-fd4c9d5c; Path=/; Secure; HttpOnly;
1 < Strict-Transport-Security: max-age=31536000; includeSubDomains
1 < traceparent: 00-000000000000000074607056ee5cc921-74607056ee5cc921-00
1 < Transfer-Encoding: chunked
1 < Vary: Accept-Encoding
1 < X-Api-Version: v12
1 < X-Content-Type-Options: nosniff
1 < X-Frame-Options: SAMEORIGIN
1 < X-Rate-Limit-Remaining: 500
1 < X-Request-ID: d2b6a3db3437b336dc93f7fee599386f
1 < X-XSS-Protection: 1; mode=block
??U[S?0~?Wt??%????????R?uggg'MO4?&i???-/??G^s?|??????05Y-?4N
?7?Q??s`<ኧ?r?&???]?p}A??p*??Ԡ??kF"&???DVY)2VD?/???H??ڝN???r&?????Bϡ???_w%??????
?}?t?1??@???Q2?;??Ɵ???X???R??0+?;??0????(B??i?"?ǜ?eᖅ??]d3?2w?
????1H?,??_,??????6_?*c
~???2?(?VG?v+?uG?U???z]?I?4?Շ??j?W?r?SaQE??6?x[M??
???W???ڛy??I?b(??:M
͢?z???0B???:}? ?]?d?_??`??i$ѹl??????J??c>?f??$????a?$??kts??Y??l???l?FH?@???A?_Bܘp????pd??B??+?&?l6?a?b彥??O??k??S?$l??c?????L???O'wyv??3uG2??:Ϗ?e?ۈ?އMSwj=~????%?YfIE?ڑ 8??3Y??i??>n?ҍ)?LP?ݧ?Q?"??B^H<ǵ????R?A?j???????
0

