Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6925083
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T10:44:40+00:00 2026-05-27T10:44:40+00:00

We have a function in our Rails code that accepts a JSON POST body:

  • 0

We have a function in our Rails code that accepts a JSON POST body:

contacts = ActiveSupport::JSON.decode(request.raw_post.gsub("+", ""))

(I’m aware that I can get this from params["_json"] as well, but we have extremely large (MBs) POST bodies that do not get put into params["_json"] for some reason (and + throws errors too).

Since the JSON is usually sent from a mobile client, it’s important to us to optimize the upload size. We want to switch to having the POST body gzipped.

However, no matter what we do, we get the same error with no line number:

MultiJson::DecodeError (743: unexpected token at ''):

We have tried:

  gzipped_contacts = Zlib::GzipReader.new(StringIO.new(request.raw_post)).read
  contacts = ActiveSupport::JSON.decode(gzipped_contacts.gsub("+", ""))

This:

   gzipped_contacts = ActiveSupport::Gzip.decompress(request.raw_post)
   contacts = ActiveSupport::JSON.decode(gzipped_contacts.gsub("+", ""))

And the solution found here: Rails: how to unzip a compressed xml request body?

I’m pretty sure this is not occurring at the controller level because I can’t log anything there, so it needs to be done in the middleware or at the server (but I can’t find anything for Nginx that lets us deflate). Please assist!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T10:44:41+00:00Added an answer on May 27, 2026 at 10:44 am

    Ok, turns out the iPhone client was sending the wrong headers. So the solution for anyone encountering this is to see the advice here:

    Rails: how to unzip a compressed xml request body?

    And verify that you are sending Content-Type: gzip/json.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have this anonymous function in our code, which is part of the jQuery's
We have a function in our code which isn't being called, but should be.
I have a function that redirects to a countdown while our system is offline,
As a toy example, suppose that we have a function called 'my_func' (the code
I need to have a routine/function/stored proc/whatever to archive particular accounts from our 'active'
I have function getCartItems in cart.js and I want to call that function in
So I have function that formats a date to coerce to given enum DateType{CURRENT,
We have 3 tables in our db that each have an entity in our
We have a function to pull RSS feeds and display the post on a
We have a function used within our PHP/MySQL application which returns basic configuration information,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.