(415)在DocuSign中发布信封时不支持的介质类型

时间:2015-06-04 17:44:56

标签: vb.net docusignapi webrequest

我在尝试发布信封时遇到此错误:

  

(415)不支持的媒体类型

这是我的代码:

Dim httpWebRequest =     DirectCast(WebRequest.Create("https://demo.docusign.net/restapi/v2/accounts/1005732/envelopes"), HttpWebRequest)

httpWebRequest.ContentType = "text/json"
httpWebRequest.Method = "POST"
httpWebRequest.Accept = "text/json"
httpWebRequest.MediaType = "text/json"

httpWebRequest.Headers.Add("X-DocuSign-Authentication", "{""Username"": ""myuser"",""Password"": ""mypassword"",""IntegratorKey"": ""mykey""}")

Using streamWriter = New StreamWriter(httpWebRequest.GetRequestStream())
Dim json As String = "{""status"": ""sent"",""emailBlurb"": ""Test Email Body"",""emailSubject"": ""Test Email Subject"",""documents"": [{""name"":   ""C:\Ant.htm"",""documentId"": ""1"",""order"": ""1""}],""recipients"":    {""signers"": [{""email"": ""eladrozman@gmail.com"",""name"":    ""Elad"",""recipientId"": ""1"",""tabs"": {""signHereTabs"": [{""xPosition"": ""100"",""yPosition"": ""100"",""documentId"": ""1"",""pageNumber"": ""1""}]}}]}}"

streamWriter.Write(json)
End Using

Dim httpResponse = DirectCast(httpWebRequest.GetResponse(), HttpWebResponse)

1 个答案:

答案 0 :(得分:0)

没有text/json这样的媒体类型。您需要将application/json用于Content-Type和其他标题。