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

  • Home
  • SEARCH
  • 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 8683295
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T22:00:14+00:00 2026-06-12T22:00:14+00:00

I have been looking at this for a while, and am currently at a

  • 0

I have been looking at this for a while, and am currently at a loss. I have narrowed the problem down to being related to JSON, and that the JSON does not appear to be being sent in a legible format.

We were previously using Rails 3.0.7 (where the problem I am about to describe did NOT exist). We need to upgrade Rails to take advantage of some new functionality – but now there is this issue. I am almost sure at this point it is a simple configuration or something, but I need some more eyes on it.

We are using ActiveResource objects, and upon setting the values of the object and saving it (thus making a PUT), we get ab 403:Forbidden returned from the remote web service. This is not a problem on the web service layer.

Upon creating a new object and making a POST, we are getting a 409:Conflict returned as it tries to update the database with default values – thus meaning the json data is not reaching the service – or is not legible.

My issue is that this worked in Rails 3.0.7, and no longer works in 3.2.3 (or 3.1.3 which I also tried). I am open to suggestions other than the JSON data, however I am pretty sure that that is where the issue is.

My ActiveResource model has

self.format = :json

I have the following in one of my initializer files:

ActiveResource::Base.include_root_in_json = false
ActiveSupport::JSON.backend = "json_gem" 

Thanks for any suggestions!

UPDATE

I have been testing out with curl and got it to work by:

curl -H "Content-Type: application/json" -d "{\"userID\":\"xxx\", \"label\":\"doc.test.test\", \"value\":\"1,19\", \"id\":\"-1\"}" -v -X POST http://host:port/usermanagement/users/xxx/prefs

I got that to work, but

  1. It appears the Content-Type header must be explicitly set otherwise it results in a 415:Media Unrecognized error

  2. If I set the Content-Type header in the ActiveResource object, I still get the 409:Conflict error – which leads me to believe the JSON is still not properly formed.

EDIT (Again)

I have figured out where the issue with the JSON is – Rails is keeping the root in the JSON.
Thus instead of sending the resource back as

{"name":"value", "name":"value"}

It is sending

{"ResourceName": {"name":"value", "name":"value"}}

However, I have set include_root_in_json to false – I tried this both in the initializer files, and directly in the model itself, and no change.

  • 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-06-12T22:00:15+00:00Added an answer on June 12, 2026 at 10:00 pm

    So I “fixed” this (worked around it) by overriding the to_json method in my model to simply return self.attributes.to_json

    class Document < ActiveResource::Base
      self.site += 'user/:user_id'
      self.element_name = "docs"
    
      def to_json(options={})
        self.attributes.to_json(options)
      end
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been looking over the internet for a while about this, but it
I've been looking for this for a while: I'm currently converting a medium-size program
I have been looking for an answer to this for a while with no
I have been looking for an answer for this for a while: I have
I have been looking at this forum on this topic for a while now
I have been looking at this for to long so I am tossing it
I have been looking over this code for the past hour, I cant see
I have been looking all over for this. I have two seperate prpt files
I have been looking for an answer to this on Stack Overflow, but I
I have been looking for some time for this and I can't seem to

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.