2017-05-09 36 views
0

我剛開始使用DocuSign API和Connect,並已發佈Webhook以接收事件通知。但是,我在管理門戶的「連接失敗」列表中找到了404未找到的錯誤。這是我的API方法的URI: http://documentsigningapi.networxsolutions.co.uk/Webhook/DocumentSigned 我已經在配置設置中的URL中發佈選項。使用Connect接收事件通知時出錯

下面是代碼:

using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Net; 
using System.Net.Http; 
using System.Web.Http; 
using System.Xml; 

namespace DocumentSigningAPI.Controllers 
{ 
    public class WebhookController : ApiController 
    {  
     public void DocumentSigned(HttpRequestMessage request) 
     {    
      var xmldoc = new XmlDocument(); 
      var result = request.Content.ReadAsStreamAsync().Result; 
      xmldoc.Load(result);   
      var mgr = new XmlNamespaceManager(xmldoc.NameTable); 
      mgr.AddNamespace("a", "http://www.docusign.net/API/3.0"); 
      XmlNode envelopeStatus = xmldoc.SelectSingleNode("//a:EnvelopeStatus", mgr); 
      XmlNode envelopeId = envelopeStatus.SelectSingleNode("//a:EnvelopeID", mgr); 
      XmlNode status = envelopeStatus.SelectSingleNode("//a:Status", mgr); 
      if (envelopeId != null) 
      { 
       System.IO.File.WriteAllText("C:/inetpub/DocumentSigningDemo/Documents/" + 
        envelopeId.InnerText + "_" + status.InnerText + "_" + Guid.NewGuid() + ".xml", xmldoc.OuterXml); 
      } 
      if (status.InnerText == "Completed") 
      { 
       // Loop through the DocumentPDFs element, storing each document. 
       XmlNode docs = xmldoc.SelectSingleNode("//a:DocumentPDFs", mgr); 
       foreach (XmlNode doc in docs.ChildNodes) 
       { 
        string documentName = doc.ChildNodes[0].InnerText; // pdf.SelectSingleNode("//a:Name", mgr).InnerText; 
        string documentId = doc.ChildNodes[2].InnerText; // pdf.SelectSingleNode("//a:DocumentID", mgr).InnerText; 
        string byteStr = doc.ChildNodes[1].InnerText; // pdf.SelectSingleNode("//a:PDFBytes", mgr).InnerText; 
        System.IO.File.WriteAllText("C:/inetpub/DocumentSigningDemo/Documents/" + envelopeId.InnerText + "_" + documentId + "_" + documentName, byteStr); 
       } 
      } 
     } 
    } 
} 
+0

這看起來更像是一個ASP.NET問題而不是docusignapi。如果它是公開可用的URL,Docusign將發佈連接通知。 –

回答

0

似乎API控制器沒有被發現,所以我現在已經把我的功能轉變爲網絡應用而不是一個API,這是現在的工作。