Skip to content
This repository has been archived by the owner on Mar 9, 2023. It is now read-only.

File downloads not working #17

Closed
eak24 opened this issue Jan 24, 2020 · 12 comments
Closed

File downloads not working #17

eak24 opened this issue Jan 24, 2020 · 12 comments

Comments

@eak24
Copy link
Contributor

eak24 commented Jan 24, 2020

Apparently STEP and ShadedViews file downloads are not working.

@rafaelhefele
Copy link

Thanks!
Could you let me know how exactly you would download STEPs/ShadedViews of a part (not partstudio) if it worked (using the python client)?
I also asked about downloading drawings. Is that currently working? If so, could you please also tell me how to download a drawing based on document-id, version-id and element-id of an onshape-app/drawing element? I'm using drawings_api.translate_format4 which doesn't seem to work as I would expect.

I would appreciate any help, thanks!

@BubuPalmer
Copy link

Hello,
I can download STEPS from the blob directly with that call:
https://cad-euw1.onshape.com:443/modelexport?workspaceId=1bcea4f3b9786f5e23662c06&microversion=ae91d6fe700e03305522a167&format=STL&mode=binary&grouping=true&scale=1.0&units=inch&_m=240af4f7&documentId=63d990e2dbf26fc0cff94e1c&elementId=628bdce768301ed4c26f20a3

This also works changing mode=text

I have no tried to download drawings.

I could upload the step using the online application. But my problem is that I can't upload any step using the API

@eak24
Copy link
Contributor Author

eak24 commented Mar 10, 2020

This is fixed... see this test, for instance: https://github.com/onshape-public/onshape-clients/blob/master/python/test/test_export.py#L6

@eak24 eak24 closed this as completed Mar 10, 2020
@BubuPalmer
Copy link

BubuPalmer commented Mar 11, 2020 via email

@BubuPalmer
Copy link

BubuPalmer commented Mar 11, 2020 via email

@BubuPalmer
Copy link

BubuPalmer commented Mar 11, 2020 via email

@eak24
Copy link
Contributor Author

eak24 commented Mar 11, 2020

Hi Victor,

The client code looks like it still needs a little tweaking in what it expects for the response. I'm working on that, but in the meantime, you can just pass in _preload_content=False to the endpoint call and the client won't attempt to deserialize the response. Also, as for the 'unverified' warning, that is just saying urlib doesn't have a mechanism to verify the ssl request, and you need to install one by doing something like this: https://urllib3.readthedocs.io/en/latest/user-guide.html#ssl

@BubuPalmer
Copy link

Ok Ethan, thank you. The first issue is solved with in _preload_content=False. But for the second one I've been trying https://urllib3.readthedocs.io/en/latest/user-guide.html#ssl. But I don't know how to apply it to the client library. Do I have to modify the source code of the library? or can I set any static or singleton parameter to enable that mechanism of verification? Is it posible to disable it too? The problem is that I don't know where do I have to apply this in the client code: urllib3.PoolManager(cert_reqs='CERT_REQUIRED',ca_certs=certifi.where())

@BubuPalmer
Copy link

Hello Ethan, with the first examples of api calls that I downloaded from Git hub it was so easy to connect. Now, since I am using the onshape_clientes 0.36, everything becomes more difficult, and I can not reuse the tests that I did before. The problem that I have now is that I can't create a new document. The client asks me for a parameter: BTDocumentParameters(). I've trying to initialize BTDocumentParameters with no arguments, as I have seen in DocumentsApi.md:

    bt_document_params = BTDocumentParams() 

    api_response = Client.get_client().documents_api.create_document(bt_document_params)

but I get this invalid empty argument error:

File "/Users/woocomerce/repos/proto-data-batch/venv/lib/python3.7/site-packages/onshape_client-0.0.36-py3.7.egg/onshape_client/oas/rest.py", line 268, in request
raise ApiException(http_resp=r)
onshape_client.oas.exceptions.ApiException: (400)
Reason: Bad Request
HTTP response headers: HTTPHeaderDict({'Server': 'nginx', 'Date': 'Wed, 11 Mar 2020 18:20:12 GMT', 'Content-Type': 'application/json;charset=utf-8', 'Content-Length': '97', 'Connection': 'keep-alive', 'On-Version': '1.110.25036.822859bf4713', 'On-Request-Id': '5d9066b22a9efc3d52a4b910', 'Strict-Transport-Security': 'max-age=31536000; includeSubDomains', 'X-Content-Type-Options': 'nosniff', 'X-XSS-Protection': '1; mode=block'})
HTTP response body: {
"moreInfoUrl" : "",
"message" : "Invalid empty argument.",
"status" : 400,
"code" : 0
}

The only think that I need is to create a new document. Please, can you tell me what is the missing parameter the I am not writing for BTDocumentParams?

Thank you

@BubuPalmer
Copy link

done:
with those parameters por BTDocumentPArams:

bt_document_params=BTDocumentParams(
owner_type=0,
name="filename",
is_public=True
)

@eak24
Copy link
Contributor Author

eak24 commented Mar 12, 2020

You can request SSL certification through the configuration object: https://github.com/onshape-public/onshape-clients/blob/master/python/onshape_client/oas/rest.py#L64 . And that is actually set by default here to false: https://github.com/onshape-public/onshape-clients/blob/master/python/onshape_client/client.py#L198 . So for right now, you can't override that setting. I'll put that on the list of things to change for the next version. Thanks for pointing this out! For now, are you OK with making the unverified requests?

@BubuPalmer
Copy link

yes, ok

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants