I make a call to an odata webservice using jaydata.js but it returns 401 Unauthorized.
Even if browse to the service and authenticate first manually in a second browser tab, is still get 401 in the first tab.
This is my code :
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script src="Scripts/datajs-1.0.3.js" type="text/javascript"></script>
<script src="Scripts/jquery-1.8.3.js" type="text/javascript"></script>
<script src="Scripts/jaydata.js" type="text/javascript"></script>
<script src="Scripts/DynamicsNav70.js" type="text/javascript"></script>
<script src="Scripts/jaydataproviders/oDataProvider.js" type="text/javascript"></script>
<script>
nav = new NAV.NAV({
name: 'oData', oDataServiceHost: 'http://XXX.cloudapp.net:7048/DynamicsNav70/OData',
user: "XXX",
password: "XXX"
});
$(document).ready(function () {
nav.Customers.forEach(function (customer) {
var item = "<li ><a href=#>@name</a></li>".replace("@name", customer.Name);
$('#customers').append(item);
});
});
</script>
<title></title>
</head>
<body>
<h1>Customers</h1>
<ul id="customers"></ul>
</body>
</html>
This is the info from by browser :
Request URL:http://XXX.cloudapp.net:7048/DynamicsNav70/OData/Customers
Request Method:OPTIONS
Status Code:401 Unauthorized
Request Headersview source
Accept:*/*
Accept-Encoding:gzip,deflate,sdch
Accept-Language:en,nl;q=0.8
Access-Control-Request-Headers:accept, maxdataserviceversion, origin, dataserviceversion
Access-Control-Request-Method:GET
Cache-Control:max-age=0
Connection:keep-alive
Host:XXX.cloudapp.net:7048
Origin:http://localhost:50793
Referer:http://localhost:50793/jaydata.html
User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.110 Safari/537.36
Response Headersview source
Content-Length:0
Date:Thu, 06 Jun 2013 14:43:12 GMT
Server:Microsoft-HTTPAPI/2.0
WWW-Authenticate:Negotiate
I'm a total noob in this matter, so any advice for a solution or better understanding of the problem could be helpfull