Closed JasonLSMART closed 2 years ago
I assume the error you are getting is a json parse error, caused by the contents of the zip file being invalid JSON. This is caused by https://github.com/asyrjasalo/RESTinstance/blob/master/src/REST/keywords.py#L1293, which passes the body of the request (ZIP file contents in your case) to the json keyword of the request method. This will in turn convert the data, which is assumed to be a JSON string to a JSON object. The parsing fails, and the request is not made.
@JasonLSMART https://github.com/asyrjasalo/RESTinstance/pull/113 added support for adding data
as an arugment to POST
and PUT
keywords, which is the same as --data
in curl
. The body
supports only JSON, but data
should support binary data as wel. Does this help?
Yes, if a working example can be documented, it would help. Thanks!
From: Aleksi Simell @.> Sent: Friday, May 7, 2021 02:12 To: asyrjasalo/RESTinstance @.> Cc: Jason Louie @.>; Mention @.> Subject: Re: [asyrjasalo/RESTinstance] POST / PUT upload file example (#101)
CAUTION: This email originated from outside of the company email system. Do not click links or open attachments unless you recognize the sender and know the content is safe.
@JasonLSMARThttps://nam02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FJasonLSMART&data=04%7C01%7Cjasonlouie%40smarttech.com%7Ca541e2b2b7a14281fb9308d9112fe316%7Cc56f91061d27456dbd203de87e595a36%7C0%7C0%7C637559719662195432%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=oOkC%2FFNZW7O4k%2FoEExM%2FupbUxYr2%2F9JVuOTC5CCm5nA%3D&reserved=0 #113https://nam02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fasyrjasalo%2FRESTinstance%2Fpull%2F113&data=04%7C01%7Cjasonlouie%40smarttech.com%7Ca541e2b2b7a14281fb9308d9112fe316%7Cc56f91061d27456dbd203de87e595a36%7C0%7C0%7C637559719662205425%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=NAGJzB8TSFi9fslfVn3ncu8HbKjOklbCfA8L7j85Ylw%3D&reserved=0 added support for adding data as an arugment to POST and PUT keywords, which is the same as --data in curl. The body supports only JSON, but data should support binary data as wel. Does this help?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://nam02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fasyrjasalo%2FRESTinstance%2Fissues%2F101%23issuecomment-834159874&data=04%7C01%7Cjasonlouie%40smarttech.com%7Ca541e2b2b7a14281fb9308d9112fe316%7Cc56f91061d27456dbd203de87e595a36%7C0%7C0%7C637559719662205425%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=3b6vTGVCZtfVjC%2FCWX541Ch7XEJU9LwIE5vhHlYmkbo%3D&reserved=0, or unsubscribehttps://nam02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAQCR4APYEMWONYE7MUJEECTTMOOHTANCNFSM4OI2GDTQ&data=04%7C01%7Cjasonlouie%40smarttech.com%7Ca541e2b2b7a14281fb9308d9112fe316%7Cc56f91061d27456dbd203de87e595a36%7C0%7C0%7C637559719662215419%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=aq%2BhcwOJs9zdIybw59xsTh5tVdz3rRKjMVZsd0OI%2FGM%3D&reserved=0.
@JasonLSMART I use this functionality in my current project like this
Get Certificate
# ...
# Calls a keyword that uses openssl to create a file called file.csr
# ...
Post <endpoint> data=file.csr headers={..., "Content-Type": "application/pkcs10"}
${cert}= Output response body
# Do stuff with ${cert}
I also have interest in this. Ive been struggling to get a multipart form file upload to work with both RequestLibrary and RESTInstance. There is very little clear information from with library on how to do this. Im using RESTInstance for all my REST testing in robot at the moment so would prefer a solution here.
@JasonLSMART I use this functionality in my current project like this
Get Certificate # ... # Calls a keyword that uses openssl to create a file called file.csr # ... Post <endpoint> data=file.csr headers={..., "Content-Type": "application/pkcs10"} ${cert}= Output response body # Do stuff with ${cert}
Is this a stand alone example? Or does it require other code to work as is?
We're combining multiple similar documentation related issues to this one. Thus renamed this to better cover all fields.
Currently in the scope of this ticket:
I have not been able to find a working example of uploading a file with POST and PUT endpoints. If there is a working example with the library, please provide an example.
I have tried the following (unsuccessfully)...