Skip to main content
Solved

Can't create a signature request using .net SDK

  • May 30, 2024
  • 6 replies
  • 301 views
  • Translate All

I’m trying to use the .NET SDK to create a signature request for a file. My code is:

public async Task<BoxSignRequest> CreateSignatureRequest(BoxUser user, string signerEmail, string emailMessage, string subject, string sourceFileId, string destinationFolderId)
{
    var userClient = GetUserClient(user); //this uses the Client Credentials Grant to get a token for the user that owns the file
    BoxSignRequestCreateRequest createRequest = new BoxSignRequestCreateRequest()
    {
        AreRemindersEnabled = true,
        AreTextSignaturesEnabled = false,
        DaysValid = 10,
        EmailMessage = emailMessage,
        EmailSubject = subject,
        ParentFolder = new BoxRequestEntity()
        {
            Id = destinationFolderId
        },
        Signers = new List<BoxSignRequestSignerCreate>() {
            new BoxSignRequestSignerCreate()
            {
                Email = signerEmail,
                LoginRequired = true,
                Role = BoxSignRequestSignerRole.signer
            }
        },
        SourceFiles = new List<BoxSignRequestCreateSourceFile>()
        {
            new BoxSignRequestCreateSourceFile()
            {
                Id= sourceFileId
            }
        }
    };

    var signRequest =  await userClient.SignRequestsManager.CreateSignRequestAsync(createRequest);
    return signRequest;
}

I’m getting a Bad Request error. The documentation on the .NET SDK is not very comprehensive so I’m wondering if anyone else can help me out here.
Thanks!

Best answer by ajankowski Box

Hi @eparshall,

The reason you’re receiving a 400 Bad Request is that the request sent by you in BoxRequestEntity object in the ParentFolder’ property lacks the required Type property, which is necessary for SignRequest in this case.

All you need to do is replace:

ParentFolder = new BoxRequestEntity()
{
    Id = destinationFolderId
}

with:

ParentFolder = new BoxRequestEntity()
{
    Id = destinationFolderId
    Type = BoxType.folder
}

I hope this helped!

View original

6 replies

Hi,
do you have Manage signature requests scope enabled in your developer console ?
Can you share a full error message ?


Best,
Lukasz

Translate

  • Author
  • New Participant
  • May 31, 2024

Yes I have manage signature requests scoped in my CCG app.

I can’t provide a full error message because my debugger stops when the box client sends the request to the box api, it just returns Bad Request without any detail as to what part of the sign request isn’t well-formed, etc.

Translate

Can you share a request_id?

Translate

Hi @eparshall,

The reason you’re receiving a 400 Bad Request is that the request sent by you in BoxRequestEntity object in the ParentFolder’ property lacks the required Type property, which is necessary for SignRequest in this case.

All you need to do is replace:

ParentFolder = new BoxRequestEntity()
{
    Id = destinationFolderId
}

with:

ParentFolder = new BoxRequestEntity()
{
    Id = destinationFolderId
    Type = BoxType.folder
}

I hope this helped!

Translate

  • Author
  • New Participant
  • June 5, 2024

That was indeed the issue, thank you.

Translate

system
  • Box Employee
  • June 25, 2024

This topic was automatically closed 4 days after the last reply. New replies are no longer allowed.

Translate