4

I have SAP Netweaver Developer account and SAP Demo System is providing ODATA Urls to public.

The OData Urls are available in the below site

http://scn.sap.com/docs/DOC-31221

Note: 1) Basic Authentication details need to be passed to access the SAP Netweaver Gateway Demo OData Urls

2) HTTPS communication is used to send and receive the data.

My question is below

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

My understanding is below

  1. I have to create the OData ExtensionProvider and access the SAP Demo System.
  2. Because of cross domain, I cannot use JSON/JSOM

Please correct me.

Update: 10 Aug 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 hostweburl;
var appweburl;

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 hostweburl;
var appweburl;

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..

  • I was trying to access the SAP Demo Data urls with the below code. – Sankara Narayanan Aug 10 '13 at 11:13
  • I'm facing the same problem. Were you able to pass the basic authentication information to the REST call? – Pascal Berger Jul 7 '14 at 6:42
0

SP.WebRequestInfo dosn't pass the authorization headers as documented in MSDN:

The following headers are stripped off: Host, TE, Authorization, UserAgent, and TransferEncoding.

It seems like using Basic Authentication with SP.WebRequestInfo is not possible.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.