2017-06-29 80 views
0

我有一个Web API2应用程序被第三方应用程序占用。当应用程序命中我的终点时,我的应用程序将发送oAuth凭据进行身份验证,并从第三方应用程序获取结果。远程服务器返回错误:(410)C#

最近有些交易失败了,当我添加一些日志时,我看到错误:远程服务器返回错误:(410)已过期发生在所有失败的事务中。不幸的是,当我打电话给我的应用程序时,我无法再现这个问题。以下是我正在使用的代码。可能是导致此错误的问题?

public async Task<customerModel> SendSigned(string url) 
{ 
    customerModel customermodel = null; 
    try 
    { 
     OAuthBase oauthBase = new OAuthBase(); 

     string oAuthKey = ConfigurationManager.AppSettings["oAuthKey"]; 
     string oAuthSecret = ConfigurationManager.AppSettings["oAuthSecret"]; 
     string timestamp = oauthBase.GenerateTimeStamp(); 
     string nonce = oauthBase.GenerateNonce(); 
     string normalizedUrl; 
     string normalizedRequestParameters; 
     string sig = HttpUtility.UrlEncode(oauthBase.GenerateSignature(
      new Uri(url), oAuthKey, oAuthSecret, string.Empty, string.Empty, 
      "GET", timestamp, nonce, out normalizedUrl, out normalizedRequestParameters)); 
     string requestUrl = String.Format("{0}?{1}&oauth_signature={2}", normalizedUrl, normalizedRequestParameters, sig); 

     HttpWebRequest request = null; 
     request = (HttpWebRequest)HttpWebRequest.Create(requestUrl); 
     using (HttpWebResponse response = (HttpWebResponse)request.GetResponse()) 
     { 
      myXMLDocument = new XmlDocument(); 
      customermodel = GetCustomerInformation(response); 
     } 

     return await Task.Run(() => customermodel); 
    } 
    catch (Exception ex) 
    { 
     _logger.Error("Error in SendSigned method", ex.InnerException); 
     return customermodel; 
    } 
} 

回答

0

410的解释是目标资源不再可用在原始服务器,这种情况很可能是永久性的基于 this链接(类似于404)

我建议你考虑一下你最近做出的修改

  1. API签名
  2. 资产/资源
  3. 文件夹重组/重组
  4. 路由改变资源
+0

这个问题是间歇性,并不会发生所有的时间

  • 重命名。所以它看起来像文件夹结构/ API签名是相同的 – Yoda

  • 相关问题