Quantcast
Channel: SCN : Popular Discussions - SAP NetWeaver Gateway Developer Center
Viewing all articles
Browse latest Browse all 1657

Access SAP Netweaver Demo OData

$
0
0

What is the best or right way to use the SAP Demo Gateway OData URL and display the data in SharePoint 2013?

 

I was trying to access the SAP Demo Data urls with the below code.

 

In firefox, google chrome browser, the authorization window is popping up and not accepting the user id and password.

In IE , i am getting the below error message

 

The security validation for this page is invalid and might be corrupted. Please use your web browser's Back button to try your operation again.

 

function GetSAPData() {

var call = jQuery.ajax({
    url
: _spPageContextInfo.webAbsoluteUrl +"/_api/SP.WebProxy.invoke",
    type
:"POST",
    data
: JSON.stringify({
                       
"requestInfo":{
                           
"__metadata":{"type":"SP.WebRequestInfo"},
                           
"Url":"https://sapes1.sapdevcenter.com/sap/opu/odata/IWBEP/GWDEMO/",
                           
"Method":"GET"
                       
}
                   
}),
headers
:{
   
"Accept":"application/json;odata=verbose",
   
"Content-Type":"application/json;odata=verbose",
   
"Authorization":"Basic <Base64 String>",
   
"X-RequestDigest": $("#__REQUESTDIGEST").val()
}
});

call
.done(function(data, textStatus, jqXHR){
   
if(data.d.Invoke.StatusCode==200){
        alert
(JSON.parse(data.d.Invoke.Body));
   
}
   
else{
       
var msg = alert(data.d.Invoke.Body);
        alert
("Error :"+ msg);
   
}
});

call
.fail(function(jqXHR, textStatus, errorThrown){
   
var response = JSON.parse(jqXHR.responseText);
   
var msg = response ? response.error.message.value : textStatus;
});    }

 

I have modified the above code and tried for public ODATA and it works fine. Here's the sample code with public odata. I guess the issue is more like sending the authentication data in HTTPS.

 

function GetSAPData() {

var call = jQuery.ajax({
    url
: _spPageContextInfo.webAbsoluteUrl +"/_api/SP.WebProxy.invoke",
    type
:"POST",
    data
: JSON.stringify({
                       
"requestInfo":{
                           
"__metadata":{"type":"SP.WebRequestInfo"},
                           
"Url":"http://datafeed.medicinehat.ca/v1/data/CityBuildings/",
                           
"Method":"GET"
                       
}
                   
}),
headers
:{
   
"Accept":"application/json;odata=verbose",
   
"Content-Type":"application/json;odata=verbose",
   
"X-RequestDigest": $("#__REQUESTDIGEST").val()
}
});

call
.done(function(data, textStatus, jqXHR){
   
if(data.d.Invoke.StatusCode==200){
        alert
(data);
   
}
   
else{
       
var msg = alert(data.d.Invoke.Body);
        alert
("Error :"+ msg);
   
}
});

call
.fail(function(jqXHR, textStatus, errorThrown){
   
var response = JSON.parse(jqXHR.responseText);
   
var msg = response ? response.error.message.value : textStatus;
});  }

 

Any hints..


Viewing all articles
Browse latest Browse all 1657

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>