FredericDH | Posts: 51

Create a package as a draft

0 votes
Hello, I am trying to create a document package and send it as a "draft". Here is the code that I have came up with : EslClient eslClient; PackageId packageId = eslClient.CreatePackage(package); if I want to create a package with a "sent" status instead of draft, I ad this line : eslClient.SendPackage(packageId); While this works, I have also found something strange : When I first create my eSL package, I use the following code : PackageBuilder packageBuilder = PackageBuilder .NewPackageNamed(packageName) .WithSettings( DocumentPackageSettingsBuilder.NewDocumentPackageSettings()) .ExpiresOn(DateTime.Today.AddDays(daysBeforeExpiration)) .WithAttributes(packageAttributes); I tried to play with the function "WithDocumentStatus()" to set the package either as a "DRAFT" or as a "SENT" package such as this : .WithStatus(DocumentPackageStatus.DRAFT) However, this doesn't seem to have any effect on the package status and the only way to set the package status seems to be my code above (create and send vs create only). Hence my question, is the function "WithStatus()" useful at all ? if yes, what is it for ? what's the purpose of marking my package as a "DRAFT" if it gets sent when I invoke "create()" then "send() ? Thanks

FredericDH | Posts: 51

Reply to: Create a package as a draft

0 votes
Oh actually, when I send a "sent" package, I now get the following error if I add the "SENT" status in the package explicitely. I dont get the error message if I dont specify the status, why ?: packageBuilder.WithStatus(DocumentPackageStatus.SENT) Could not create a new package. Exception: The remote server returned an error: (400) Bad Request. HTTP POST on URI https://sandbox.esignlive.com/api/packages. Optional details: {"messageKey":"error.validation.sendPackage.noApprovals","message":"Cannot send package without approvals.","code":400,"name":"Validation Error"}

harishaidary | Posts: 1812

Reply to: Create a package as a draft

0 votes
Hi Frederic, When doing a createPackage() call, the package will automatically be placed in draft. There isn't really a need to define .WithStatus() method. The SDK is built in such a way that it will create your package with the signer information and package settings(includes package status), upload your documents, and send the package (if you are using CreateAndSendPackage()). Hence, when you are trying to create a package with a SENT status, then you will get the error above as the SDK didn't upload the documents/add signatures just yet. The .WithStatus() should really only be used when doing a eslClient.createPackageOneStep(). This call creates a multipart/form-data request and creates and uploads your package in one request. Therefore, the .WithStatus() method is valid in this situation.

Hello! Looks like you're enjoying the discussion, but haven't signed up for an account.

When you create an account, we remember exactly what you've read, so you always come right back where you left off