locked
Azure web app unable call third party rest api RRS feed

  • Question

  • User1466256281 posted

    Hi 

    I have web API . That it is hosted two different place ( Azure VM and azure web  ) and this web app call the third party web site with authorisation token (bearer )re 

    1) Azure VM  hosted web site perfectly run 

    2) But Azure Web app   web site exception (object reference not ) 

    Thursday, January 5, 2017 8:52 AM

All replies

  • User61956409 posted

    Hi Rituranjan,

    Azure Web app   web site exception (object reference not ) 

    Do you mean that when you call third party rest api from your application that is hosting on Azure website, it returns exception? Do you try to use remote debug feature to debug the code to find the issue?

    With Regards,

    Fei Han

    Saturday, January 7, 2017 6:32 AM
  • User1466256281 posted

    I try it . It Object reference exception but VM there is no exceptions

    Saturday, January 7, 2017 6:40 PM
  • User1466256281 posted

    I debug the azure web app 

    In debug information we get URL and token that is work in postman & same code hosted in VM but not run in azure web apps

    Sunday, January 15, 2017 1:25 AM
  • User1466256281 posted

    Hi 

    we are using following code please suggest me this code is run in VM but not run in azure web app.

        public string GetRequest(string accessToken, string contentType,string url)
            {
                var response = "";
                
                var resourceGroupsrequest = (HttpWebRequest)WebRequest.Create(url);
                if (!string.IsNullOrEmpty(accessToken))
                {
                    resourceGroupsrequest.Headers.Add(HttpRequestHeader.Authorization, "Bearer " + accessToken);
                }
                resourceGroupsrequest.ContentType = contentType;// "application/json";
                var resourceGroupsResponse = (HttpWebResponse)resourceGroupsrequest.GetResponse();
                Console.WriteLine(resourceGroupsResponse.StatusDescription);
                var resourceGroupsreceiveStream = resourceGroupsResponse.GetResponseStream();
                // Pipes the stream to a higher level stream reader with the required encoding format. 
                if (resourceGroupsreceiveStream == null) return response;
                var rateCardreadStream = new StreamReader(resourceGroupsreceiveStream, Encoding.UTF8);
                response = rateCardreadStream.ReadToEnd();
    
                return response;
            }

        public string GetRequest(string accessToken, string contentType,string url)        {            var response = "";                        var resourceGroupsrequest = (HttpWebRequest)WebRequest.Create(url);            if (!string.IsNullOrEmpty(accessToken))            {                resourceGroupsrequest.Headers.Add(HttpRequestHeader.Authorization, "Bearer " + accessToken);            }            resourceGroupsrequest.ContentType = contentType;// "application/json";            var resourceGroupsResponse = (HttpWebResponse)resourceGroupsrequest.GetResponse();            Console.WriteLine(resourceGroupsResponse.StatusDescription);            var resourceGroupsreceiveStream = resourceGroupsResponse.GetResponseStream();            // Pipes the stream to a higher level stream reader with the required encoding format.             if (resourceGroupsreceiveStream == null) return response;            var rateCardreadStream = new StreamReader(resourceGroupsreceiveStream, Encoding.UTF8);            response = rateCardreadStream.ReadToEnd();
                return response;        }

    Sunday, January 15, 2017 9:51 AM
  • User1466256281 posted

    Hi  

    You have any idea request http to https using c#

    Monday, January 16, 2017 5:55 PM