Unable to upload gzipped json file (not using a Multipart upload)

232 views
Skip to first unread message

Michael Hicks

unread,
Aug 25, 2016, 12:35:21 AM8/25/16
to REST assured
Hey all, 
I'm trying to upload a gzipped json to a microservice and I can't make this request to work in Rest-assured.
Here's the request I'm trying to make, that works perfectly when send using cURL or any REST client: 
curl -v -s -XPOST --url http://54.164.67.59/omnivore/tickets -H 'Content-Type: application/json' -H 'Content-Encoding: gzip' --data-binary @/Users/mikehicks/Dev/Github/pos-srv/omnivore/testdata/ticket_added.json.gz


Multi-part form data uploading method doesn't work with the micro-service I'm working on.

Here's how I send it:

String gzippedBinary = "/Users/mikehicks/Dev/Github/qa-tests/src-pos/test/resources/testOmnivoreTickets/ticket_added.json.gzip";
File file = new File(gzippedBinary);
byte[] array = Files.readAllBytes(file.toPath());




InputStream inputStream = new FileInputStream(file);
   
Response response =
    given
()
       
.body(array)
       
.header("Content-Encoding", "gzip")
       
.header("Content-Type", "application/json")
   
.when()
       
.post("/omnivore/tickets")
   
.then()
       
.extract()
       
.response();


Here's what is being actually sent:
https://goo.gl/kHxAwn - Request sent using method above
Looks like the encoding is different and it's not an actual gzipped file.

Here's the successful request sent using a reset client:

Any help appreciated.
Thanks!

Johan Haleby

unread,
Aug 25, 2016, 1:57:17 AM8/25/16
to rest-a...@googlegroups.com
Hi,

What version of rest assured are you using? While it shouldn't make a difference you could try adding "Content-Type" before "body".

You can also try out the rest-assured curl logger and compare the output with your original command. 

Regards,
/Johan


--
You received this message because you are subscribed to the Google Groups "REST assured" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rest-assured+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Michael Ovchinnikov

unread,
Sep 28, 2016, 11:49:21 AM9/28/16
to REST assured
Thanks Johan, I was actually using 2.9.0 and updating to 3.0.1 resolved the issue (code snipped I pasted above worked just fine).
Reply all
Reply to author
Forward
0 new messages