ユーザマニュアル





2023/09/08

MANUAL

FAQ:サンプルコード:添付ファイルを含んだレコードを新規作成したい

## 概要 添付ファイルを含んだレコードをAPIを使用して新規作成します。 ##### 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 } ```
TOP
このページをシェアする
記載された商品名、各製品名は各社の登録商標または商標です。 © Implem Inc.