Reputation: 1396
I'm learning to use codeigniter and in general to create the API.
I have installed REST_Controller in my project, I have created in my db the table 'logs' and 'keys' using the query that I found in the Rest.php file.
Now If I do a get, the method works. But if I tried to do a post (from Postman) I receive this error:
"status": false,
"error": "Invalid API Key "
I have done a post to link: localhost/..../controllername/create (so without using create_post) and I pass values using body/form-data in Postman.
If I see the data inside the 'logs' table, i can see the post with the values that I have passed, but I have no values about the api_key parameter, while the 'keys' table is completely empty.
How can I do to resolve this error?
Upvotes: 0
Views: 1888
Reputation: 104
Go to config/rest.php and set the API KEY name you wil send, default is:
$config['rest_key_name'] = 'X-API-KEY';
You can change for any other like: token, authtoken, etc. If you are using tools like Postman try send in the headers: name: X-API-KEY value: your_token_value
Upvotes: 1
Reputation: 1876
If you are using postman, you need to set Authorization to basic and pass following values, which is default you should change it in your config/rest.php
file. Also you can set your API keys for different users in your db table. Please study the rest_controller files on github.
username = 'admin'
password = '1234'
Upvotes: 0