Ask Your Question

is it possible to call identity restful api with javascript

asked 2012-03-14 02:32:40 -0500

jekie8 gravatar image

I want to call identity restful api with ajax in my html page,my code as below: <html><head><title>test identity restful api</title>

<script type="text/javascript" src="json.js"/> <script type="text/javascript"> var xmlHttp; function initXmlHttp() { if(window.XMLHttpRequest){xmlHttp=new XMLHttpRequest();} else if(window.ActiveXObject){xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");} } function statechange() { if(xmlHttp.readystate==4 && xmlHttp.status==200){document.getElementById("id1").innerHTML=xmlHttp.responseText;} } function sendRequest() { var data={ "auth":{ "passwordCredentials":{ "username":"admin", "password":"openstack" }, "tenantName":"Admin" } }; initXmlHttp();"POST","",true); xmlHttp.onreadystatechange=statechange; xmlHttp.setRequestHeader("Content-Type","application/json"); xmlHttp.setRequestHeader("Accept","application/json"); xmlHttp.send(JSON.stringify(data)); } </script>

</head> <body>

<input type="button" value="test api" onclick="javascript:sendRequest();"/> </body> </html>

I still get 404 error information in firefox firebug console,I get totally confused,any help will be appreciated!

edit retag flag offensive close merge delete

4 answers

Sort by ยป oldest newest most voted

answered 2012-03-14 06:45:46 -0500

try "" instead of ""

at least, v2 will get 404 via curl.

edit flag offensive delete link more

answered 2012-03-15 06:41:02 -0500

jekie8 gravatar image

i have also tried "",the result is disappointing too....

edit flag offensive delete link more

answered 2012-03-16 02:39:48 -0500

heckj gravatar image

Im afraid I don't know javascript well enough to help tell you what's not happening correctly. The data structure you're sending looks generally correct to request a token.

The correct API URI is /v2.0/tokens to request a token with credentials.

I recommend that you watch the logs of keystone while you're making this request, and make sure that "debug" is in the pipeline for the public API - that will dump out everything that keystone is seeing form the request, and may make debugging easier.

relevant lines in keystone.conf::

pipeline = token_auth admin_token_auth xml_body json_body debug ec2_extension public_service
edit flag offensive delete link more

answered 2012-03-17 16:11:51 -0500

gongysh gravatar image

Correct url should be: http://localhost:5000/v2.0/tokens .

But the main problem should be about cross-domain.

please have a look at (

edit flag offensive delete link more

Get to know Ask OpenStack

Resources for moderators

Question Tools

1 follower


Asked: 2012-03-14 02:32:40 -0500

Seen: 355 times

Last updated: Mar 17 '12