# 1.9.3 Encoding Error w/ compressed data http request header

**URL:** <https://www.ruby-forum.com/t/1-9-3-encoding-error-w-compressed-data-http-request-header/189357>\
**Category:** Ruby\
**Created:** [May 29, 2010, 5:40pm UTC](https://www.ruby-forum.com/t/1-9-3-encoding-error-w-compressed-data-http-request-header/189357 "2010-05-29T17:40:13Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![biot023](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/7ab992/32.png) [@biot023](https://www.ruby-forum.com/u/biot023)\
**Post date:** [May 29, 2010, 5:40pm UTC](https://www.ruby-forum.com/t/1-9-3-encoding-error-w-compressed-data-http-request-header/189357/1 "2010-05-29T17:40:13Z")

</div>

Hi – it’s possible that I’m getting all of this _entirely_ wrong, so I  
thought I’d post what I’m trying to do here & see what comes back.  
Basically, I have a RoR web service that has bulk\_create and bulk\_update  
methods in one of its controllers.  
These take ActiveResource-style JSON hashes of potentially many objects  
to create or update.  
The service is JSON, so what I’ve been doing is using HTTParty to send  
the post and put requests to the service url with the objects data to be  
created or updated in the query string.  
Naturally, I quickly ran into issues with the amount of data that I  
could send that way, so I added compression with Zlib to the service,  
and to the client calling it.  
The client code, for example, looks a little like this:

My::Service( :put, “/objects/bulk\_create.json”, query: { objects\_doc:  
Zlib::Deflate.deflate( objects.to\_json ) } )

This fixed the issue.  
However, I’m now updating the service to run on Ruby 1.9.3, and am  
running into encoding issues (apparently the bane of many a Ruby coder’s  
life at the moment, although I’m only upgrading from 1.9.1).  
The error I’m actually getting is this: “invalid byte sequence in UTF-8  
(ArgumentError)”  
So I guess I have two questions:

1. How can I fix this so that it works again?
2. _Should_ I fix it, or is there another way that I should be sending  
data to my web service?  
Cheers,  
Doug.

---

<div class="post-metadata">

**Author:** ![biot023](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/7ab992/32.png) [@biot023](https://www.ruby-forum.com/u/biot023)\
**Post date:** [June 2, 2010, 2:24am UTC](https://www.ruby-forum.com/t/1-9-3-encoding-error-w-compressed-data-http-request-header/189357/2 "2010-06-02T02:24:15Z")

</div>

On Sun, May 30, 2010 at 12:40:16AM +0900, Doug L. wrote:

> could send that way, so I added compression with Zlib to the service,  
> The error I’m actually getting is this: “invalid byte sequence in UTF-8  
> (ArgumentError)”  
> So I guess I have two questions:
> 
> 1. How can I fix this so that it works again?
> 2. _Should_ I fix it, or is there another way that I should be sending  
> data to my web service?

Can you reduce the problem to code the breaks outside of your particular  
application? This sounds like something that _should_ work, but it’s  
difficult for people to help if they can’t reproduce the problem.
