0

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?

2 Answers 2

1

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

Sign up to request clarification or add additional context in comments.

Comments

0

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'

1 Comment

I have changed the authorization to basic, I have used the default username and password, but i receive always the same message

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.