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.
Having issue when using onshape api for download stl file

Hi i am very first time to use onshape tools and api. i am currently studying this for my project.
This is my .py file for loading stl file.
from onshape_client.client import Client
with open("config.txt") as cfg:
theta = float(cfg.readline().split("=")[1])
config = {
"base_url": "https://cad.onshape.com",
"access_key": "——",
"secret_key": "——"
}
client = Client(configuration=config)
document_id = "8439fb43c437263e5ddf1d36"
workspace_id = "35d8bc1ad49b2648a97c9da9"
element_id = "9aa403259ef60bf62302022b"
full_url = (
f"{config['base_url']}"
f"/api/partstudios/d/{document_id}"
f"/w/{workspace_id}"
f"/e/{element_id}/stl"
)
config_str = f"theta={theta}degree"
response = client.api_client.request("GET", full_url, query_params={"configuration": config_str})
if response.status == 200:
with open("output.stl", "wb") as f:
f.write(response.data.encode("utf-8"))
print(f"STL for θ={theta} written to output.stl")
else:
print("Error:", response.status, response.data)
This code works very well but it cannot change the parameter. i set my modeling's parameter as 'theta' and the .py file cannot change it.
I tried browser version of stl file, https://cad.onshape.com/api/partstudios/d/8439fb43c437263e5ddf1d36/w/35d8bc1ad49b2648a97c9da9/e/9aa403259ef60bf62302022b/stl?configuration=theta=2+degree ,
but it also make same result. please feel free to give some tips for me. thank you for reading.
Comments
you need to URL encode the configuration string
configuration=theta%3D2%2Bdegree
Custom FeatureScript and Onshape Integrated Applications
You can find documentation and examples for encoding your configurations here: https://onshape-public.github.io/docs/api-adv/configs/ . You'll see examples for using configurations in both synchronous and asynchronous exports.