Strategy for API using Codeigniter REST!
- Aadil P.
What was needed?
An existing codeigniter application needed to be fixed, and API endpoints needed to be created for a mobile application.
How we tackled it?
We implemented REST CodeIgniter API using the RESTful library by CHRIS
. The controllers worked flawlessly out of the box but there was also a requirement for a standalone controller to take care of certain data-exchange, and REST was not an option.
A controller was coded to accept the post data, process it and returned the desired result in JSON format.
All tests using postman and via jQuery.ajax turned out successful until tests were done from the mobile application itself.
Apparently, the mobile application was not sending form-data or x-www-form-urlencoded data. The application was sending JSON data with application/json
header which PHP was unable to read using the $_POST or $this->input->post() class of CodeIgniter.