API access fails

asked 2017-06-22 00:58:56 -0600

Elangovan Anganann gravatar image

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 http://10.0.0.11:35357/v3/auth/tokens  -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
gAAAAABZS1rRFgQr6GAdj_H1eeaMIIvAAc-2zhJMIzDO1t0AFnGfYoiYIdZrssVhWPCSuBDyNWkp2OarATdS4cMugB4OaabV9NPwsqAtY7CjbgUL8aZXkJHksGd66fcl5KCTV5o4ARCKfC0nxvOf6M2xV6MkWodV-8O19HEL9pDH9ELIzVX63Yo

[root@controller1 ~ (admin)]# curl -g -i -X GET http://10.0.0.11:35357/v3/users? -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.
</body></html>

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 |
+----------------------------------+--------+
edit retag flag offensive close merge delete

Comments

What happens when you remove the question mark after v3/users?

Bernd Bausch gravatar imageBernd Bausch ( 2017-06-22 01:29:42 -0600 )edit