0

I am trying to sent a Rest API Call via PowerShell Invoke-RestMethod Cmdlet but I keep getting BAD REQUEST 400 response:

RESPONSE

Object
status_code: 400
message: "Invalid document list"

I need to make this request using PowerShell because it would integrate perfectly a program I am currently working on in this language that has a windows form GUI.

I am sending some test calls to a sandbox environment and this is my current code (I am obviously omitting token and other confidential information):

$filePath = 'C:\test\ITFormAPITest.pdf';
$SandboxURL = "https://api.sandbox.signaturit.com/v3/signatures.json"
$headers = @{"Authorization"="Bearer myTOKEN"}
$Body = @{
"recipients[0][name]"="myNAME";
"recipients[0][email]"="myEMAILADDRESS";
"files[0]"= $filePath;
"subject"="Subject Test";
"body"="Please review and sign this. Thanks!"}

Invoke-RestMethod -WebSession $session -Uri $SandboxURL -Method "POST" -Body $Body -Headers $headers -ContentType "application/x-www-form-urlencoded"

Signaturit is a tool that allows to send document via email to request a digital signature from the recipient. I was able to send API requests via Postman where I can specify the key type (file or text) but I do not know how to specify the type in PowerShell and that is why when sending a rest api call, my file parameters is actually parsed as a text parameters, see screenshot below:

enter image description here

Any advice? I have tried to contact their support but they have nobody seems to know how to do this using PowerShell. Thanks

Please see links below on how to use the API and how to register for the sandbox: Signaturit API Instructions: https://docs.signaturit.com/api/latest#signatures_create_sign Sandbox Registration Page: https://app.sandbox.signaturit.com/en/register/personal Sandbox Environemnt Access Token Location: https://dashboard.sandbox.signaturit.com/en/#/settings/integrations

Andy Deegee
  • 21
  • 1
  • 5

1 Answers1

0

Managed to find myself a workaround thanks to the brainstorming with a dear friend of mine. I did not know that I could just include a cURL code in my PowerShell script and that is what I did:

curl.exe `
-X POST `
-H "Authorization: Bearer ACCESS_TOKEN" `
-F "recipients[0][name]=RECIPIENT_NAME" `
-F "recipients[0][email]=RECIPIENT_EMAIL" `
-F "subject=SUBJECT_EMAIL" `
-F "body=BODY_EMAIL" `
-F "files[0]=@C:\PATH\FILE_TO_UPLOAD.EXT" `
URL_FOR_THE_API_CALL
Andy Deegee
  • 21
  • 1
  • 5