kamranwali

Cannot edit or delete package

0 votes

Hi,

I am getting following error while trying to update the expiry date of a package

OneSpanSign.Sdk.OssServerException: Could not send the package. Exception: The remote server returned an error: (403) Forbidden. HTTP POST on URI https://sandbox.esignlive.com/api/packages/2nHUDBSB23inrZk_XfnR9b4sM4Y=. Optional details: {\"technical\":\"package: 2nHUDBSB23inrZk_XfnR9b4sM4Y= cannot be edited.\",\"messageKey\":\"error.forbidden.cannotEditDeletePkg\",\"message\":\"Cannot edit or delete package.\",\"code\":403,\"name\":\"Access Denied\"} ---> OneSpanSign.Sdk.OssServerException: The remote server returned an error: (403) Forbidden. HTTP POST on URI https://sandbox.esignlive.com/api/packages/2nHUDBSB23inrZk_XfnR9b4sM4Y=. Optional details: {\"technical\":\"package: 2nHUDBSB23inrZk_XfnR9b4sM4Y= cannot be edited.\",\"messageKey\":\"error.forbidden.cannotEditDeletePkg\",\"message\":\"Cannot edit or delete package.\",\"code\":403,\"name\":\"Access Denied\"} ---> System.Net.WebException: The remote server returned an error: (403) Forbidden.\r\n at System.Net.HttpWebRequest.GetResponse()\r\n at OneSpanSign.Sdk.Internal.HttpMethods.PostHttp(String apiKey, String path, Byte[] content, IDictionary`2 headers)\r\n --- End of inner exception stack trace ---\r\n at OneSpanSign.Sdk.Internal.HttpMethods.PostHttp(String apiKey, String path, Byte[] content, IDictionary`2 headers)\r\n at OneSpanSign.Sdk.RestClient.Post(String path, String jsonPayload)\r\n at OneSpanSign.Sdk.Services.PackageService.SendPackage(PackageId packageId)\r\n --- End of inner exception stack trace ---\r\n at OneSpanSign.Sdk.Services.PackageService.SendPackage(PackageId packageId)\r\n at OneSpanSign.Sdk.OssClient.SendPackage(PackageId id)

 

The code I am using to update the package is

PackageId ossPackageId = new PackageId(documentSignatureResendDto.PackageId);

            DocumentPackage package = ossClient.GetPackage(ossPackageId);
            ossClient.ChangePackageStatusToDraft(ossPackageId);

            package.ExpiryDate = documentSignatureResendDto.ExpiresOn;
            ossClient.UpdatePackage(ossPackageId, package);
           
            ossClient.SendPackage(ossPackageId);

 

Can you please check what is wrong here?

 

Thanks,

Kamran

 


Reply to: Cannot edit or delete package

0 votes

Hi Kamran,

 

Thanks for your post! I can reproduce the same error with this code, and you just need to change the order to these two lines to resolve the issue (change package to draft first, then get package):
 

            PackageId ossPackageId = new PackageId("C_ejhz7t2XqlHiEodYrdo1beMXc=");

            ossClient.ChangePackageStatusToDraft(ossPackageId);
            DocumentPackage package = ossClient.GetPackage(ossPackageId);

            package.ExpiryDate = DateTime.Parse("2023-05-01");
            ossClient.UpdatePackage(ossPackageId, package);

            ossClient.SendPackage(ossPackageId);

 

PS: This is because if you get package first, the local package.Status is still SENT and this attribute has higher priority than package.Due, which will directly send out the transaction without setting the expiry in .UpdatePackage(), and cause this 403 error in the last .SendPackage() since the transaction is already SENT.

 

Duo

 

Duo Liang OneSpan Evangelism and Partner Integrations Developer


Reply to: Cannot edit or delete package

0 votes

Hi Duo,

 

 Changing the order worked.

 

Thanks,

Kamran


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