我将通过设置舞台来启动它。我是vb.net和编程的新手。我们正在将我们的前端Access程序转换为vb.net。在此过程中,有人在我们的程序转换时开始使用FormStack,WebMerge和CudaSign。我们的程序处理FormStack和WebMerge的东西,我们现在想要的是能够将这些文档发送给CudaSign以便客户能够签名。 经过几天的研究,我已经能够成功创建用户并检索上传文件所需的令牌。 我的指示对我没什么帮助,因为我对此没有任何了解。
cURL声明是: 卷曲-H'授权:持票人ACCESS_TOKEN'-F'文件= @ FILE_NAME'https://capi-eval.signnow.com/api/document
到目前为止我所拥有的:
Public Shared Function postFile(ByVal url As String, toSerialize As String, strHeader As String) As DataTable
Dim strmFile As New FileStream(toSerialize, FileMode.Open, FileAccess.ReadWrite)
Dim wHeader As WebHeaderCollection = New WebHeaderCollection
wHeader.Clear()
wHeader.Add(strHeader)
Dim wReq As WebRequest = WebRequest.Create(url)
'Dim postData As String = toSerialize
wReq.Headers = wHeader
wReq.Method = "POST"
wReq.ContentType = "multipart/form-data"
wReq.ContentLength = strmFile.Length
Dim dataStream As Stream = wReq.GetRequestStream()
Dim inData As Byte() = New Byte(strmFile.Length - 1) {}
Dim bytesRead As Integer = strmFile.Read(inData, 0, strmFile.Length)
dataStream.Write(inData, 0, strmFile.Length)
strmFile.Close()
Dim wResp As WebResponse = wReq.GetResponse()
MsgBox(CType(wResp, HttpWebResponse).StatusDescription)
dataStream = wResp.GetResponseStream()
Using reader As New StreamReader(dataStream)
Dim respFromServer As String = reader.ReadToEnd()
Dim dtCudaFile As DataTable = JsonConvert.DeserializeObject(Of DataTable)("[" & respFromServer & "]")
MsgBox(dtCudaFile.Rows(0).ToString)
iqSTAMP.gvCudaClients.DataSource = dtCudaFile
reader.Close()
dataStream.Close()
wResp.Close()
Return dtCudaFile
End Using
Return Nothing
End Function
我的问题是什么是-F ='file = @ FILE_NAME'期待的?字符串似乎不起作用。也许更具体的是什么是@?另外,有更好的方法吗?
此处还有用于创建客户端的cURL语句: curl -H'授权:基本ENCODED_CLIENT_CREDENTIALS' - 数据'{“first_name”:“测试”,“last_name”:“用户”,“电子邮件”:“user@test.com”,“密码”:“测试”} 'https://capi-eval.signnow.com/api/user
我的代码成功运行了这个:
Public Shared Function postRequest(ByVal url As String, ByVal toSerialize As Object, strHeader As String) As DataTable
Dim wHeader As WebHeaderCollection = New WebHeaderCollection
wHeader.Clear()
wHeader.Add(strHeader)
Dim wReq As WebRequest = WebRequest.Create(url)
Dim postData As String = JsonConvert.SerializeObject(toSerialize)
Dim byteArray As Byte() = Encoding.UTF8.GetBytes(postData)
wReq.Headers = wHeader
wReq.Method = "POST"
wReq.ContentType = "application/json"
wReq.ContentLength = byteArray.Length
Dim dataStream As Stream = wReq.GetRequestStream()
dataStream.Write(byteArray, 0, byteArray.Length)
dataStream.Close()
Dim wResp As WebResponse = wReq.GetResponse()
MsgBox(CType(wResp, HttpWebResponse).StatusDescription)
dataStream = wResp.GetResponseStream()
Using reader As New StreamReader(dataStream)
Dim respFromServer As String = reader.ReadToEnd()
Dim dtCudaClient As DataTable = JsonConvert.DeserializeObject(Of DataTable)("[" & respFromServer & "]")
MsgBox(dtCudaClient.Rows(0).ToString)
iqSTAMP.gvCudaClients.DataSource = dtCudaClient
reader.Close()
dataStream.Close()
wResp.Close()
Return dtCudaClient
End Using
Return Nothing
End Function
更新:我找到了Fiddler,并通过CudaSigns网站上传了一个文件。这是它的格式:
POST https://signnow.com/proxy/index.php/document HTTP/1.1
Host: signnow.com
Connection: keep-alive
Content-Length: 130269
Cache-Control: max-age=0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Origin: https://signnow.com
User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.90 Safari/537.36
Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryKL4kOmxYJU4yAmfq
Referer: https://signnow.com/app/account?upload=1429548553882
Accept-Encoding: gzip, deflate
Accept-Language: en-US,en;q=0.8
Cookie: SNTooltipPresentation-Session-DockFirstTime=true; __distillery=v20150227_62e2ac9d-afa9-4bf4-bcb9-f274dd69dde1; email=pcasey%40infoqwest.net; SNTooltipPresentation-Session-SignatureWindow=true; signnowpurchasecookie=twelve_dollars_per_user; _ga=GA1.2.1823410227.1427173595; AWSELB=71BF89DD1C8E4B50D0322FBC8BE6CADD106081F9D15080EB8ED1032966C88138EDD4A5CB885B172D889C54E0A93AE079C744AE6A31914D5F430F7EF5D17B7728585B6641D1; visitor_id10742=354511558; __utma=187131127.1823410227.1427173595.1429500610.1429548417.4; __utmb=187131127.11.9.1429548510020; __utmc=187131127; __utmz=187131127.1429500610.3.3.utmcsr=google|utmccn=(organic)|utmcmd=organic|utmctr=(not%20provided); session=m05vam1n9uh1pcaptnk7c9lfl3; isActiveMember=true; SNTooltipPresentation-Session-addFields=true
------WebKitFormBoundaryKL4kOmxYJU4yAmfq
Content-Disposition: form-data; name="file"; filename="CudaSignTest.pdf"
Content-Type: application/pdf
(then there is the encoded file stream)
这看起来更接近我看过的关于通过vb.net webrequest上传文件的一些帖子,但我仍然对于发生了什么以及他们的示例如何转换为此而感到迷茫。提前感谢您的帮助。
答案 0 :(得分:0)
WebMerge实际上与CudaSign集成(称为交付),您可以使用它自动发送文档以进行签名,而无需进行任何编程。您是否尝试过使用该集成?