Revision history [back]

click to hide/show revision 1
initial version

API access fails

I am trying to access openstack using curl. I got the token successfully. But when I try to list the users, I get "400 Bad request" error. But when I try to run "openstack user list", it succeeds. What did I do wrong in my curl command?

[root@controller1 ~ (admin)]# unset TOKEN
[root@controller1 ~ (admin)]# echo $TOKEN

[root@controller1 ~ (admin)]# export TOKEN=$(curl -si -X POST  -H "Content-Type: application/json"  -d '{"auth": {"scope": {"project": {"domain": {"name": "Default"}, "name": "admin"}}, "identity": {"password": {"user": {"domain": {"name": "Default"}, "password": "admin123", "name": "admin"}}, "methods": ["password"]}}}' | awk '/X-Subject-Token/ {print $2}')

[root@controller1 ~ (admin)]# echo $TOKEN

[root@controller1 ~ (admin)]# curl -g -i -X GET -H "User-Agent: python-keystoneclient" -H "Accept: application/json" -H "X-Auth-Token: $TOKEN"
HTTP/1.0 400 Bad request
Cache-Control: no-cache
Connection: close
Content-Type: text/html

<html><body><h1>400 Bad request</h1>
Your browser sent an invalid request.

Here is the output of "openstack user list" command.

[root@controller1 ~ (admin)]# openstack user list
| ID                               | Name   |
| 35e74dfcd02946d1ae95467f14c3bfb8 | admin  |
| 43a43aea47b74a04a17e18cff384d520 | demo   |
| 7fc29f86bcba415a99a33686ddff8724 | glance |
| ca067441510147379304f1eac18e5454 | cinder |