willman
willman

Reputation: 1201

INVALID_REQUEST_PARAMETER on DocuSign.eSign.Api.EnvelopesApi

I am experiencing the exact same error as described in question INVALID_REQUEST_PARAMETER on listStatus

However, unlike that OP, I am not using the REST API directly, but am using the C# SDK from https://www.nuget.org/packages/DocuSign.eSign.dll

It would appear that the SDK wrapper is not including the querystring parameters as described by the answer in the above linked post. Is there a workaround other than waiting for DocuSign to fix their SDK -- and where is the appropriate place to submit a bug for their SDK?

Per comment, here is a code sample:

var envelopesApi = new DocuSign.eSign.Api.EnvelopesApi();
var envelopeIds = incentivesWithPendingOffers.Select(i => i.new_OfferLetterEnvelopeID).ToList();
var envelopeInfos = await envelopesApi.ListStatusAsync(_tokenAccountId, new EnvelopeIdsRequest(envelopeIds), null);

Running fiddler to capture the outbound REST call being made by the SDK, I see this:

PUT https://demo.docusign.net/restapi/v2/accounts/[ REDACTED ]/envelopes/status HTTP/1.1
X-DocuSign-SDK: C#
Authorization: Bearer [ REDACTED ]
Accept: application/json
User-Agent: Swagger-Codegen/2.1.0/csharp
Content-Type: application/json
Host: demo.docusign.net
Content-Length: 96
Accept-Encoding: gzip, deflate

{"envelope_ids":["1d324bac-60ea-44b5-9b60-a5de14af3beb","5431d728-4918-4218-9c12-765b1c914724"]}

which returns the following response (which the SDK turns into a .NET Exception):

HTTP/1.1 400 Bad Request
Cache-Control: no-cache
Content-Length: 238
Content-Type: application/json; charset=utf-8
X-DocuSign-TraceToken: [ REDACTED ]
Date: Wed, 01 Aug 2018 20:43:58 GMT
Strict-Transport-Security: max-age=31536000; includeSubDomains

{
  "errorCode": "INVALID_REQUEST_PARAMETER",
  "message": "The request contained at least one invalid parameter. Query parameter 'from_date' must be set to a valid DateTime, or 'envelope_ids' or 'transaction_ids' must be specified."
}

Upvotes: 0

Views: 809

Answers (2)

Drew
Drew

Reputation: 5029

When the previous answer was written, the SDK didn't support putting the list of envelope IDs in the call body. As of client version 3.1.3 this is now available.

        List<string> envelopeIds = new List<string>();
        envelopeIds.Add("2b62eb63-784a-4228-be02-876762ea6661");
        envelopeIds.Add("406a9a15-c8e9-4227-8dd2-bd9a5318d4fd");

        EnvelopeIdsRequest envelopeIdsRequest = new EnvelopeIdsRequest();
        envelopeIdsRequest.EnvelopeIds = envelopeIds;

        ListStatusOptions options =  new ListStatusOptions();
        options.envelopeIds = "request_body"; //the Options value controls the query string parameter

        EnvelopesInformation envelopesInfo = envelopesApi.ListStatus(accountId, envelopeIdsRequest, options);

Upvotes: 1

Drew
Drew

Reputation: 5029

I wasn't able to use the envelope_ids=request_body parameter via the SDK, but I was able to get status of several envelopes at once. This would be a viable workaround as long as you're not requesting so many envelope IDs that the URL overflows.

        EnvelopesApi.ListStatusChangesOptions lsco = new EnvelopesApi.ListStatusChangesOptions
        {
            envelopeIds = "fdd1122a-9c1b-4eef-9e24-25bb2cdf2eb2, fe1cb500-6a4c-4328-bf24-55806434852f, 5b1d3828-f8cd-4bba-87f0-538cb920db96"
        };

        EnvelopesInformation listStatusChanges = envelopesApi.ListStatusChanges(accountId, lsco);

results in an API call to

GET https://demo.docusign.net/restapi/v2/accounts/{{accountId}}/envelopes?envelope_ids=fdd1122a-9c1b-4eef-9e24-25bb2cdf2eb2%2C%20fe1cb500-6a4c-4328-bf24-55806434852f%2C%205b1d3828-f8cd-4bba-87f0-538cb920db96

Upvotes: 0

Related Questions