PowerShell-带有文本和文件的Indoke -RestMethod
我正在尝试通过PowerShell Invoke-restmethod cmdlet发送REST
API
Object
status_code: 400
message: "Invalid document list"
呼叫此请求使用PowerShell,因为它将完美地集成了我目前正在使用具有Windows Form GUI的语言进行的程序。
我正在向沙盒环境发送一些测试调用,这是我当前的代码(我显然正在省略令牌和其他机密信息):
$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是一种工具,允许通过电子邮件发送文档以向收件人请求数字签名。我能够通过Postman发送API请求,可以在其中指定密钥类型(文件或文本),但我不知道如何指定PowerShell中的类型,这就是为什么在发送REST API调用时,我的文件参数实际上是对的。作为文本参数,请参见下面的屏幕截图:
有建议吗?我试图联系他们的支持,但他们似乎没有人知道如何使用PowerShell做到这一点。谢谢
请参阅下面的链接,介绍如何使用API以及如何注册沙箱: Signaturit API Instructions: https://docs.signaturit.com/api/latest#signatures_create_sign 沙盒注册页面: https://app.sandbox.sign.signaturit.com/en/register/个人 SandBox Enviremnt访问令牌位置: https://dashboard.sandboard.signboard.signerit.com/ en/#/设置/集成
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:
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
得益于我的一个亲爱的朋友的头脑风暴,他设法找到了解决方法。我不知道我可以在PowerShell脚本中包括一个卷曲代码,这就是我所做的:
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: