docusign / docusign-esign-csharp-client

The Official Docusign C# Client Library used to interact with the eSignature REST API. Send, sign, and approve documents using this client.
https://developers.docusign.com/docs/esign-rest-api/sdks/csharp/
MIT License
129 stars 159 forks source link

INVALID_REQUEST_PARAMETER on DocuSign.eSign.Api.EnvelopesApi #196

Closed ewillman closed 5 years ago

ewillman commented 6 years ago

the following code:

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);

results in an INVALID_REQUEST_PARAMETER exception.

I have capture the http request and response from this code with fiddler: request:

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"]}

the response:

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."
}

There is a nearly identical error reported on stackoverflow by a developer using the REST API directly, and the answer was to add an additional querystring parameter to the request URI (https://stackoverflow.com/questions/50644862/invalid-request-parameter-on-liststatus), but obviously, this would require modification of the SDK.

RajRele commented 6 years ago

Hi @ewillman This is an issue with the way swagger-codegen is setting up the optional parameters. We don't want you to be getting a huge set of Envelopes, thus the API is asking for a date range. We understand that the reference does not say it out loud that these are required parameters. We will add this to our backlog to update our API Reference to clear the confusion. To resolve your issue can you please try using the below "options" and give a date range to your query.

 // This example gets statuses of all envelopes in your account going back 30 days...
DateTime fromDate = DateTime.UtcNow;
fromDate = fromDate.AddDays(-30);
string fromDateStr = fromDate.ToString("o");

// set a filter for the envelopes we want returned using the fromDate and count properties
EnvelopesApi.ListStatusOptions options = new EnvelopesApi.ListStatusOptions()
{
fromDate = fromDateStr
};

// in your code please add the options parameter instead of passing it null
var envelopeInfos = await envelopesApi.ListStatusAsync(_tokenAccountId, new EnvelopeIdsRequest(envelopeIds), options);
alexroode commented 6 years ago

@RajRele, I am also facing this issue. I tried specifying FromDate as you suggested. The call went through without an error. However, it seemed to ignore the EnvelopeIds I specified in my EnvelopeIdsRequest - and returned data for all envelopes in since the FromDate, including the ones I didn't ask for.

It seems that regardless of the FromDate, the client is not communicating the EnvelopeIds correctly to the API.

Perhaps the issue is a missing query string parameter envelope_ids=request_body as mentioned in the link referenced by @ewillman? https://stackoverflow.com/questions/50644862/invalid-request-parameter-on-liststatus

RajRele commented 6 years ago

@alexroode Sorry to hear that you are facing this issue. We have already opened an internal investigation to fix this (Jira# DCM-2748). We will update this conversation once we have a release. Thanks for your patience...

RajRele commented 5 years ago

Hi, We have fixed the issues with new eSignature API version and new SDK release candidate. Please have a look at NuGet Store v3.1.3-rc

You can now send envelopeIds as a query parameter or in the request object. We have a v3.1.3-rc branch. Please have a look at these test methods ListStatusChanges and ListStatus

Let us know if this resolves the issue. Thanks

tedPen commented 5 years ago

I was encountering this issue on the Ruby client, @RajRele will this fix be included there?

RajRele commented 5 years ago

Hi @tedPen, Sorry that you are facing this. We are working on getting the Ruby Client work these issue fixes plus many swagger-spec upgrades. I don't have a expected completion date yet.

For now, I recommend using the raw API to get yourself unblocked for Ruby client. Endpoint -> PUT /v2/accounts/{accountId}/envelopes/status?envelope_ids=request_body

You need to pass the query parameter as envelope_ids=request_body to read envelopeIds from request body.

And body will look like below: {     "envelopeIds": [         "fill in envelope id#1",         "fill in envelope id#2"     ] }

For Ruby: We will be tracking and updating you with our progress here: https://github.com/docusign/docusign-ruby-client/issues/15

Thank you for your patience.

RajRele commented 5 years ago

Thanks @ewillman, closing this issue as resolved. Please open a new issue if you have any questions.