0

Can we use Cisco based Custom web service in SharePoint-hosted app on Office 365?

My requirement is get items from Cisco based Custom web service and display items in SharePoint Environment (Office 365) using SharePoint Hosted app.

But its getting error Status code: 401,The remote server returned the following error while establishing a connection - 'Unauthorized'

Here is code:-

$(document).ready(function () {

    (function () {
        alert('Executed');
        var context = SP.ClientContext.get_current();

        var request = new SP.WebRequestInfo();

        request.set_url(
            "http://Otherdomain/BookingService.asmx"
            );        
        request.set_method("GET");

        request.set_headers({ "Accept": "application/json;odata=verbose" });
        var response = SP.WebProxy.invoke(context, request);

        context.executeQueryAsync(successHandler, errorHandler);

        function successHandler() {
            if (response.get_statusCode() == 200) {
                // Load the OData source from the response.
                var responseData = JSON.parse(response.get_body());
                // log this to console so you can inspect it
                console.log(responseData)
            }
            else {
                var errordesc = "Status code: " + response.get_statusCode();
                errordesc += "\n" + response.get_body();
                alert(errordesc);
               // console.log(errordesc)
                txtOutput.text = errordesc;
            }
        }
        function errorHandler() {
            //console.log(response.get_body());
            txtOutput.text = 'Error';
        }
    })();

});

How we provide the Network Credentials details for custom web service on SharePoint-hosted app development ?

2

You have to add a RemoteEndPoint to your solution. In the appmanifest, go to the tab 'Remote End Points'and write the url where you need to consume the information

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.