When I tried to get list of Sales from Dear Systems, I've got an error response of 500 Internal Server Error. I have this following codes.
string xmlStringResult = string.Empty;
string url = _cred.StoreName + "/SaleList";
try
{
var req = (HttpWebRequest)WebRequest.Create(url);
req.Method = "GET";
req.ContentType = "application/xml";
req.Headers.Add("api-auth-accountid", _cred.AccountId);
req.Headers.Add("api-auth-applicationkey", _cred.APIKey);
using (var resp = (HttpWebResponse)req.GetResponse())
{
if (resp.StatusCode != HttpStatusCode.OK)
{
string message = String.Format("Call failed. Received HTTP {0}", resp.StatusCode);
AppendLog(string.Format("Error: {0}", message));
return xmlStringResult;
}
var sr = new StreamReader(resp.GetResponseStream());
xmlStringResult = sr.ReadToEnd();
}
}
catch (Exception ex)
{
AppendLog(string.Format("Error: {0}", ex.Message));
}
return xmlStringResult;
Please advice and Thank you.
Assuming the error was truly the response from the Dear Systems (not error caught in your catch block) :
Do you have control over the Dear Systems?