I am getting this error while trying to post an envelope:
(415) Unsupported Media Type
Here is my code:
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"": ""[email protected]"",""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)
There's no such media type as
text/json
. You need to useapplication/json
for the Content-Type and other headers.