Status code: 401 The remote server returned the following error while establishing a connection - 'Unauthorized'.


  hi,

can use third party custom web services in sharepoint-hosted app on office 365  ?

 i try value custom web services in sharepoint-hosted app development.but getting error "

status code: 401,the remote server returned following error while establishing connection - 'unauthorized'".

my 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 odata source response.
                var responsedata = json.parse(response.get_body());
                // log console 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';
        }
    })();

});

can give network credentials details on sharepoint-hosted app development ?


thanks

akash anand

hi aakash,

i suggest can call custom web service in browser firstly , trace web response using fiddler check if web service needs specific token or credential access.

http://www.telerik.com/fiddler

thanks

best regards


technet community support
please remember mark replies answers if help, , unmark answers if provide no help. if have feedback technet support, contact tnmff@microsoft.com.



SharePoint  ,  Apps for Office and SharePoint  >  Developing Apps for SharePoint 2013



Comments

Popular posts from this blog

Azure DocumentDB Owner resource does not exist

job syspolicy_purge_history job fail in sqlserver 2008

Trying to register with public marketplace error with 'Get-AzureStackStampInformation'