codeigniter-restserver: Can't retrieve GET parameter

Hi,

My URL is like this: http://api.mydomain.com/assets/1234/ Wherein 1234 is the ID.

I’ve tried everything but I can’t seem to retrieve the ID in my code. Not using index_get() or something similar. Anyone got an idea why this isn’t working?

Even if I add something extra in my URL like api.mydomain.com/assets/id/1234/ I am not able to retrieve the ID by using id_get(). Possible bug?

About this issue

  • Original URL
  • State: closed
  • Created 11 years ago
  • Comments: 19

Most upvoted comments

I am having the same issue as edwardmp above, and here’s what I’ve found:

If your method name is index_get(), then I can’t find anyway to access any additional parameters after the method in the URL - trying to do so, will always generate an [“unknown method”] error in my experience. My URL looks like this: www.mysite.com/api/controller/index_get (where my api calls are just made to : /api/controller, which works - I was hoping to do be able to follow up with api/controller/id/…)

If you change the method from index_get() to somename_get(), then you can access the remaining URI segments using different means like: $this->uri->segment(3) in the controller.

Ideally, I wanted to break up each controller (and file) for each resource (and rely on the index_get, index_put etc. methods for each file) - attempting to keep things better organized, instead of having really long controllers.

The snag must be in REST_Controller somewhere. Does anyone have any additional info on this? Or is my one-file approach off for any reason?

Thanks very much.

PS - I can access parameters in the query string with the index_get method, like api/controller?id=123, but I’m hoping to satisfy other requirements and format the URL like api/controller/123. Thanks.