2 years ago
#46019
user1185081
How to POST data to my Rails 5.2 application API with Curl, with authentication?
I recently had to upload data to my Rails application API using Curl. To make it short, I bypassed the Devise authentication for this specific API. But now it's time to enforce authentication, prior to deployment. This is just a question of adding an Authorization header to the request, isn't it?
I built the following header using login:password with Base64 encoding:
-H "Authorization:Basic QWRtaW46I1Byb3RvdHlwZTEzIQ=="
Unfortunately, I do not manage to implement Curl's authentication to Devise for posting to the API:
curl --noproxy localhost
-d @external_activities.json
-H "Authorization:Basic QWRtaW46I1Byb3RvdHlwZTEzIQ=="
-H "Content-type: application/json"
http://localhost/API/external_activities
The application returns the status 401 Unauthorized
.
Thank you for your help!
ruby-on-rails
curl
devise
0 Answers
Your Answer