User Manual

10.01.2024

MANUAL

FAQ: I want to download attachments in a batch process

## Answer Use the "[Attachment Retrieval API](/en/manual/api-attachment-get)". --- ## Overview If you want to download attachments in a batch process, use the "[Attachment Retrieval API](/en/manual/api-attachment-get)". Use PowerShell to download attachments for any record. ## Operation Procedure 1. Create a table and attach a file to the record. 1. Open Windows PowerShell and write the following script content. 1. Change the values ​​of [servername], $requestUrl, and $apiKey to suit your environment. ``` $requestUrl = "http://[servername]/api/binaries/[Guid]/get" $apiKey = "[api key]" ``` To get the Guid of a record, follow the link below. [API Function: Retrieve Single Record](/manual/api-record-get) ### Execution Result The attachments will be downloaded to C:Works. ![image](https://pleasanter.org/binaries/60dd4cfceed2406f814233d30898f780) ## Sample Code ##### PowerShell ``` Add-Type -AssemblyName "System.Web" $error.Clear() $requestUrl = "http://[servername]/api/binaries/XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/get" $apiKey = "XXXXXXXX..." $path = "C:\Works" trap [Net.WebException] { continue; } try{ $json = @{ ApiKey = $apiKey } $requestBody = $json | ConvertTo-Json -Depth 3 $res = Invoke-RestMethod -Uri $requestUrl -ContentType "application/json" -Method POST -Body ${requestBody} Write-Output $res $byte = [System.Convert]::FromBase64String($res.Response.Base64) [System.IO.File]::WriteAllBytes($path + "\" + $res.Response.FileName, $byte) } catch { Write-Output $_.Exception } if ($error.Count -gt 0) { Write-Output $error[0].ErrorDetails.Message | ConvertFrom-Json } ``` ## Related Information <div id="ManualList"><ul><li><a href="/en/manual/api-attachment-get">Developer Function: API: Table Operation: Retrieve Attachments</a><span>10.01.2024 up</span></li></ul></article></div><input id="SearchTextHidden" type="hidden" value="" />
TOP
このページをシェアする
記載された商品名、各製品名は各社の登録商標または商標です。 © Implem Inc.