I am using the codeigniter rest server api library.
When I enter http://localhost/projects/myapi/key/index_put.php and hit enter gives me the following error:
<xml>
<status>0</status>
<error>Invalid API Key</error>
</xml>
When I give a dummy string in the url, like:
http://localhost/projects/myapi/key/index_put.php?X-API-KEY=asldfj9alsdjflja97979797997
I get the same problem. Any idea?
index_put.php
:
public function index_put() {
// Build a new key
$key = self::_generate_key();
// If no key level provided, give them a rubbish one
$level = $this->put('level') ? $this->put('level') : 1;
$ignore_limits = $this->put('ignore_limits') ? $this->put('ignore_limits') : 1;
// Insert the new key
if (self::_insert_key($key, array('level' => $level, 'ignore_limits' => $ignore_limits))) {
$this->response(array('status' => 1, 'key' => $key), 201); // 201 = Created
} else {
$this->response(array('status' => 0, 'error' => 'Could not save the key.'), 500); // 500 = Internal Server Error
}
}
i faced the same issue .don't mention put/get/post in URL ,RestServer itself recognizes the request nature base on parameter you pass two step required to solve your problem .
http://localhost/projects/myapi/key/index_put.php
must change to :
http://localhost/projects/myapi/key/index.php
create an api kay using
sha1
(max 40 character) in the keys table (table structure show in config/rest.php file), enter 1 inis_private_key
field and ::1 inip_address
field. create the record ,and check it again .