Skip to main content
Solved

Can't create a signature request using .net SDK


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
Did this topic help you find an answer to your question?

6 replies

  • Participating Frequently
  • 15 replies
  • May 31, 2024

Hi,

do you have Manage signature requests scope enabled in your developer console ?

Can you share a full error message ?



Best,

Lukasz


  • Author
  • New Participant
  • 3 replies
  • 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.


  • Participating Frequently
  • 15 replies
  • May 31, 2024

Can you share a request_id?


  • Participating Frequently
  • 21 replies
  • Answer
  • June 5, 2024

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!


  • Author
  • New Participant
  • 3 replies
  • June 5, 2024

That was indeed the issue, thank you.


system
  • Community Manager
  • 22 replies
  • June 25, 2024

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


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings