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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T12:04:04+00:00 2026-06-06T12:04:04+00:00

I have a problem right now with CodeIgniter : I use the REST Controller

  • 0

I have a problem right now with CodeIgniter : I use the REST Controller library (which is really awesome) to create an API but I can not get PUT requests…

This is my code :

function user_put() {
    $user_id = $this->get("id");
    echo $user_id;
    $username = $this->put("username");
    echo $username;
}

I use curl to make the request :

curl -i -X PUT -d "username=test" http://[...]/user/id/1

The user_id is full but the username variable is empty. Yet it works with the verbs POST and GET.
Have you any idea please?

Thank you !

  • 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-06T12:04:07+00:00Added an answer on June 6, 2026 at 12:04 pm

    According to: http://net.tutsplus.com/tutorials/php/working-with-restful-services-in-codeigniter-2/ we should consult https://github.com/philsturgeon/codeigniter-restserver/blob/master/application/libraries/REST_Controller.php#L544 to see that this method:

    /**
     * Detect method
     *
     * Detect which method (POST, PUT, GET, DELETE) is being used
     * 
     * @return string 
     */
    protected function _detect_method() {
      $method = strtolower($this->input->server('REQUEST_METHOD'));
    
      if ($this->config->item('enable_emulate_request')) {
        if ($this->input->post('_method')) {
          $method = strtolower($this->input->post('_method'));
        } else if ($this->input->server('HTTP_X_HTTP_METHOD_OVERRIDE')) {
          $method = strtolower($this->input->server('HTTP_X_HTTP_METHOD_OVERRIDE'));
        }      
      }
    
      if (in_array($method, array('get', 'delete', 'post', 'put'))) {
        return $method;
      }
    
      return 'get';
    }
    

    looks to see if we’ve defined the HTTP header HTTP_X_HTTP_METHOD_OVERRIDE and it uses that in favor of the actual verb we’ve implemented on the web. To use this in a request you would specify the header X-HTTP-Method-Override: method (so X-HTTP-Method-Override: put) to generate a custom method override. Sometimes the framework expects X-HTTP-Method instead of X-HTTP-Method-Override so this varies by framework.

    If you were doing such a request via jQuery, you would integrate this chunk into your ajax request:

    beforeSend: function (XMLHttpRequest) {
       //Specify the HTTP method DELETE to perform a delete operation.
       XMLHttpRequest.setRequestHeader("X-HTTP-Method-Override", "DELETE");
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm facing a strange problem right now... I'm trying to use Facebook API to
I have a problem right now, I need to parse an XML but some
I have come across quite a wired problem right now. I am using ASP.NET
I have a problem here. Right now I'm doing my Web Based Application, my
Right now I have some troubles. I'm finding a way to solve one problem.
I'm having a problem right now, I have 2 domain classes namely Doctor and
I have a tough problem right now. I am having a big dictionary file
Okay, so I have the weirdest problem right now. My code is fine! It
I'm new to Twig and like it, but i've got one problem right now.
So I know you can use output buffer. The problem right now is, 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.