ユーザマニュアル





2024/04/29

MANUAL

FAQ:バッチ処理で添付ファイルを含んだレコードを新規作成したい

## 回答 「[レコード作成API](/manual/api-record-create)」を使用してください。 --- ## 概要 バッチ処理で添付ファイルを含んだレコードを作成したい場合は、「[レコード作成API](/manual/api-record-create)」を使用します。POSTするデータの「Attachments」オブジェクトに「[JSONデータレイアウト:Item](/manual/api-item)」に記載の内容を設定してください。 ## サンプルコード ##### PowerShell ``` Add-Type -AssemblyName "System.Web" $error.Clear() $requestUrl = "http://servername/api/items/2/create" $apiKey = "af14A56RE68ssa320..." $file = Get-Item "C:\Work\Test.pptx" trap [Net.WebException] { continue; } try{ $contentType = [System.Web.MimeMapping]::GetMimeMapping($file.FullName) $base64filelist = New-Object System.Collections.ArrayList [void]$base64filelist.Add(@{ Name = $file.Name ContentType = $contentType Base64 = [Convert]::ToBase64String([System.IO.File]::ReadAllBytes($file.FullName)) }) $json = @{ ApiKey = $apiKey Title = "Test" AttachmentsHash = @{ AttachmentsA = $base64filelist } } $requestBody = $json | ConvertTo-Json -Depth 3 $res = Invoke-RestMethod -Uri $requestUrl -ContentType "application/json" -Method POST -Body ${requestBody} Write-Output $res } catch { Write-Output $_.Exception } if ($error.Count -gt 0) { Write-Output $error[0].ErrorDetails.Message | ConvertFrom-Json } ``` ## 関連情報 <div id="ManualList"><ul><li><a href="/manual/api-record-create">開発者向け機能:API:テーブル操作:レコード作成</a><span>2023/08/16 up</span></li></ul></article> <ul><li><a href="/manual/api-item">開発者向け機能:JSONデータレイアウト:Item</a><span>2023/10/05 up</span></li></ul></article></div><input id="SearchTextHidden" type="hidden" value="" />
TOP
このページをシェアする
記載された商品名、各製品名は各社の登録商標または商標です。 © Implem Inc.