is it possible to call identity restful api with javascript

Asked by jekie zhang on 2012-03-14

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={


<div id="id1"></div><br/>
<input type="button" value="test api" onclick="javascript:sendRequest();"/>

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

Question information

English Edit question
Keystone Edit question
No assignee Edit question
Last query:
Last reply:
xyj (xyj-asmy) said : #1

try "" instead of ""

at least, v2 will get 404 via curl.

jekie zhang (jekie8) said : #2

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

Joseph Heck (heckj) said : #3

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

yong sheng gong (gongysh) said : #4

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

But the main problem should be about cross-domain.

please have a look at

Can you help with this problem?

Provide an answer of your own, or ask jekie zhang for more information if necessary.

To post a message you must log in.