0
votes

I wrote this curl command which doesn't seem to work.

curl -H "Content-Type: application/json" -X PUT "Authorization: Bearer {token}" -d "{"login":"user1","password":"xxx"}" https://localhost:8443/users/user1 -k

I tried to change quotation marks but it doesn't work either. All I got is

curl: (6) Could not resolve host: Authorization

{"error":"unauthorized","error_description":"Full authentication is required to access this resource"}

The Authorization works fine though. I'm sure the token is correct.

1

1 Answers

2
votes

The -H flag is missing in front of the Authorization header.

Try

curl -H "Content-Type: application/json" -H "Authorization: Bearer {token}" \
-X PUT -d '{"login":"user1","password":"xxx"}' \
https://localhost:8443/users/user1 -k

Because that was missing it was not seeing that as a header, but part of the request URL.

To test, I decode with this in PHP:

var_dump(json_decode(stream_get_contents(fopen('php://input', 'r'))));