8

I am using Adobe EchoSign web service to create a SendDocument function in vb.net. I tried the solution in this post Using EchoSign API in VB.net but no luck.

I am getting an error

Value of type 'String' cannot be converted to 'secure.echosign.com.ArrayOfString'

in my code below at .recipients = recipients(0)

Public Sub SendDocument(ByVal apiKey, ByVal fileName, ByVal formFieldLayerTemplateKey, ByVal recipient)  

Dim recipients() As String = recipient

Dim docRecipient As RecipientInfo = New RecipientInfo()
With docRecipient
    .email = recipient
    .fax = "800-123-4567"
    .role = RecipientRole.SIGNER
End With

Dim docCreationInfo As DocumentCreationInfo = New DocumentCreationInfo()
With docCreationInfo
     .recipients = docRecipient(0)
     .name = Path.GetFileName(File.Name)
     .message = TestMessage
     .fileInfos = fileInfos
     .signatureType = SignatureType.ESIGN
    .signatureFlow = SignatureFlow.SENDER_SIGNATURE_NOT_REQUIRED
End With

When I try .recipients = recipients the error reads

Value of type '1-dimensional array of String' cannot be converted to 'secure.echosign.com.ArrayOfString'.

Any suggestions on how to resolve the error?

Community
  • 1
  • 1
user3929962
  • 517
  • 3
  • 6
  • 23
  • 1
    As a side note, I went to their [documentation](https://secure.echosign.com/public/docs/EchoSignDocumentService19;jsessionid=29262C93133E6755EDC83EDFE65DD9E6.ord-prod-app3#DocumentCreationInfo) to see what `tos` is expecting and it says `Note: the tos field has been deprecated. Users should instead use the recipients field which allows for both signers and approvers.` – j.f. Aug 18 '14 at 16:12
  • Thanks JF. The recipients field is also expecting an array and I get the same error message when using recipients field. I updated my question. – user3929962 Aug 18 '14 at 17:38
  • Is your recipients array an array of `RecipientInfo` objects? – j.f. Aug 18 '14 at 17:59
  • Have you tried: Dim recipients() As String = {recipient} and then .recipients = recipients with no index? – Jason Hughes Aug 18 '14 at 18:06
  • @j.f. yes it is of type RecipientInfo. – user3929962 Aug 18 '14 at 18:10
  • .recipients(0) = docRecipient resolved the error. But now I am getting a "Object reference not set to an instance of an object" at the same line. – user3929962 Aug 18 '14 at 18:25
  • Ok, I would think you would want to assign an array to `.recipients`, rather than assigning a single object to the first index. But either way, what is null now? Have you set a break point and figured that out? – j.f. Aug 18 '14 at 18:45
  • docRecipient contains values. The error "Object reference not set to an instance of an object" occurs at ".recipients(0) = docRecipient" – user3929962 Aug 18 '14 at 18:53
  • My guess is it is because how you are assigning. `.recipients` is most likely null because you just created its parent object new. So trying to access an indexer of it would give that error. Try throwing `docRecipient` into an array of `RecipientInfo` and assign the array to `.recipients`. – j.f. Aug 18 '14 at 19:06

1 Answers1

1

Try assigning an array of RecipientInfo objects to the .recipients field:

'create a RecipientInfo object
Dim docRecipient As RecipientInfo = New RecipientInfo
With docRecipient
    .email = recipient
    .fax = "800-123-4567"
    .role = RecipientRole.SIGNER
End With

'create a RecipientInfo array with your new object as its contents
Dim recipients() As RecipientInfo = { docRecipient }

'create a DocumentCreationInfo and assign the array to the recipients field
Dim docCreationInfo As DocumentCreationInfo = New DocumentCreationInfo
With docCreationInfo
    .recipients = recipients
    .name = Path.GetFileName(File.Name)
    .message = TestMessage
    .fileInfos = fileInfos
    .signatureType = SignatureType.ESIGN
    .signatureFlow = SignatureFlow.SENDER_SIGNATURE_NOT_REQUIRED
End With
j.f.
  • 3,844
  • 2
  • 25
  • 38