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 8658445
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T15:46:11+00:00 2026-06-12T15:46:11+00:00

I’m working on a RESTful application using CodeIgniter and I’m unable to access my

  • 0

I’m working on a RESTful application using CodeIgniter and I’m unable to access my POST’d json data in my controller.

I’m posting the json via cURL on my local machine, while the app is being developed on a remote server.

Here is the controller code in question:

class Products extends CI_Controller
{
  public function __construct()
  {
    $this->load->model(products_model);
  }
  public function index($id = FALSE)
  {
    if($_SERVER['REQUEST_METHOD'] == 'GET')
    {
      // fetch product data
      $product_data = $this->products_model->get_products($id)

      // set appropriate header, output json
      $this->output
        ->set_content_type(application/json)
        ->set_output(json_encode($product_data));
    }
    elseif($_SERVER['REQUEST_METHOD'] == 'POST')
    {
      // debugging for now, just dump the post data
      var_dump($this->input->post());
    }

  }
}

The GET action is working well enough, and returning the appropriate data when requested from a browser, or via a cURL request. However, when attempting to POST json data via cURL I consistently get bool(FALSE) returned from the POST section of the index function. Here is the cURL request I’m making:

curl -X POST -d @product.json mydomain.com/restfulservice/products

Also, here is the contents of the product.json file:

{"id":"240",
"name":"4 x 6 Print",
"cost":"1.5900",
"minResolution":401,
"unitOfMeasure":"in",
"dimX":0,
"dimY":0,
"height":4,
"width":6}

I’ve made another POST via cURL, excluding the json data and passing something like this:

curl -X POST -d '&this=that' mydomain.com/restfulservice/products

Which returns

array(1) {
  ["this"]=>
  string(4) "that"
}

What gives? Something with the json? It’s valid. I’ve turned off the global CSRF and XSS in application/config/config.php as I understand they require use of CI’s form_open() and won’t work properly without it. It’s my understanding that excluding parameters from $this->input->post() will return ALL the post items yet I continue to get none. I’ve also tried going around CI’s input library and accessing the data via PHP’s $_POST variable, it has made no difference.

  • 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-12T15:46:12+00:00Added an answer on June 12, 2026 at 3:46 pm

    Your post data is not in query string format so you should skip dealing with $_POST and go straight to the raw post data.

    try

    var_dump($HTTP_RAW_POST_DATA);
    

    or even better

    var_dump(file_get_contents("php://input")); 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say I'm outputting a post title and in our database, it's Hello Y’all
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I want to construct a data frame in an Rcpp function, but when I

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.