FAQ: I want to create a new record with attachments in batch processing
## Answer
Please use the "「Record Creation API」".
---
## Summary
If you want to create records that include attachments in batch processing, use the "「Record Creation API」". Set the contents described in "[JSON Data Layout: Item](/en/manual/api-item)" in the "Attachments" object of the data to be posted.
## Sample Code
##### 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
}
```
## Related Information
<div id="ManualList"><ul><li><a href="/en/manual/api-item">Developer Function: JSON Data Layout: Item</a><span>08.14.2024 up</span></li></ul></article></div><input id="SearchTextHidden" type="hidden" value="" />