Hi,
I have created the web api URL to get the data from SQL database. Now i want to call that api in SharePoint hosted app REST api call. If i call that url it will get the data and show it in SharePoint. I have called this using the normal Ajax call but it throws an error.
$.ajax({
url: "../_api/SP.WebProxy.invoke",
type: "POST",
data: JSON.stringify(
{
"requestInfo": {
"__metadata": { "type": "SP.WebRequestInfo" },
"Url": externalUrl,
"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",
"X-RequestDigest": $("#__REQUESTDIGEST").val()
},
I have tried this way. but it shows the forbidden error. Can anyone please suggest the solution?
Thanks in advance.