Basic Authentication Using Jquery/ajax
I am trying to create basic authentication page where my form has three fields username password grant type On submitting a form I just want to display returned response from a
Solution 1:
I usually add Headers like this ( the code is from a "Query a remote service using the web proxy in Sharepoint", here ) :
$.ajax({
url: "../_api/SP.WebProxy.invoke",
type: "POST",
data: JSON.stringify(
{
"requestInfo": {
"__metadata": { "type": "SP.WebRequestInfo" },
"Url": url,
"Method": "GET",
"Headers": {
"results": [{
"__metadata": { "type": "SP.KeyValue" },
"Key": "Accept",
"Value": "application/json;odata=verbose",
"ValueType": "Edm.String"
}]
}
}
}),
headers: {
"Accept": "application/json;odata=verbose",
"Content-Type": "application/json;odata=verbose",
"Authorization": "yourkeyvalueforauthorizationEXAMPLE",
"X-RequestDigest": $("#__REQUESTDIGEST").val()
},
success: successHandler,
error: errorHandler
});
Let me know how it goes
Post a Comment for "Basic Authentication Using Jquery/ajax"