0

I have an test API (get method) which I have deployed on production with test data.

This API if I call from anywhere directly from Browser , it works perfectly. I created a web application, just a submit click button, to call that API. I deployed web application on Azure.

It doesn't work. It keeps giving me Operation has timed out exception. API doesn't get a hit. API get request works from browser. I tried to using logger in api, log file remains blank.

Can please anyone help me in this?

EDIT:

When I call through browser, I get following response

This XML file does not appear to have any style information associated with it. The document tree is shown below.

<ArrayOfMessage xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/ValidationWebApi">

<Message>

<MessageDesc>

[{"NO":"111","NAME":"Miss Jane ","EXTENSION":"","MOBILE":"","EMAIL_ID":SOME EMAIL ID}]

</MessageDesc>

<MessageId i:nil="true"/>

<WebApiInfo i:nil="true"/>

<isValid>1</isValid>

</Message>

</ArrayOfMessage>

But if I call through Azure hosted site, I get following error...

`System.Net.WebException: The operation has timed out at System.Net.WebClient.DownloadDataInternal(Uri address, WebRequest& request) at System.Net.WebClient.DownloadString(Uri address) at System.Net.WebClient.DownloadString(String address) at Test.btnSubmit_Click(Object sender, EventArgs e)

Edit:

The way this has been called to check whether it gets hit or not is as follows This is button click event. we are just trying to print this response on screen. Get method is used.

string strApi = "https://domain.com/myApiName/Jane";
try
    {
        using (var client = new WebClient())
        {
         var result = client.DownloadString(strApi);
         Response.Write(result);

        }

}

I get exception on var result statement. It waits there for sometime and gives exception.

Regards, Ashay

Ashay
  • 1
  • 1
  • Please add the code on how you are calling the API from your web application. – Ravi A. Sep 09 '16 at 11:53
  • The same URL set for strApi works in browser ? – Ravi A. Sep 09 '16 at 12:22
  • Yes. if I put that URL in browser, I get appropriate result. – Ashay Sep 09 '16 at 12:24
  • Does it work locally i.e. if you point it to local webAPI and not the one hosted in Azure? Also your production server is accessible over internet right ? – Ravi A. Sep 09 '16 at 12:38
  • Can you make any outbound calls from the Azure machine attempting to call your hosted API? – LDJ Sep 09 '16 at 12:57
  • Hi, @Ravi, It does work locally. I can access my production server from anywhere, even from my mobile internet chrome, api direct call works fine. LDJ -> if I mention some other api, which are there live in production, those gets appropriate hits, but not this one. We have even put logger as soon as it gets hit, but when this particular api called from azure, it doesnt even get hit. – Ashay Sep 09 '16 at 13:08
  • Can you explain more about the deployment of both web app and web API i.e. is it hosted n app service or Virtual Machine? – Ravi A. Sep 09 '16 at 14:20
  • Web app is deployed on azure web app service. and aPi on our production domain. – Ashay Sep 14 '16 at 05:17

1 Answers1

0

Try enabling CORS ( cross-origin HTTP request ) to you API controller ..

Thanks Kasam Shaikh

Kasam Shaikh
  • 319
  • 2
  • 6