Create a request.txt File
For the Attachment object, the notation for these fields is particularly important:
- The Name field is the file name of the binary attachment. The easiest way to get a unique name for each attachment in your batch is to use the relative path from the base directory to the binary attachment. For example, attachment1.gif or subdir/attachment2.doc.
- The Body is the relative path to the binary attachment, preceded with a # symbol. For example, #attachment1.gif or #subdir/attachment2.doc.
- The ParentId field identifies the parent record, such as an account or a case, for the attachment.
The batch file can also include other optional Attachment fields, such as Description. For more information, see Attachment.
Sample CSV request.txt File
This sample CSV file includes two Attachment records. The first record references an attachment1.gif binary file in the base directory of the zip file. The second record references an attachment2.doc binary file in the subdir subdirectory of the zip file. In this example, the ParentId field indicates that both attachments are associated with Account parent records. The Account Id variable should be replaced with the Id of the associated parent account.
Name,ParentId,Body
attachment1.gif,Account Id,#attachment1.gif
subdir/attachment2.doc,Account Id,#subdir/attachment2.doc
Sample XML request.txt File
This sample XML file includes the same two records as the previous CSV sample file.
<?xml version="1.0" encoding="UTF-8"?>
<sObjects
xmlns="http://www.force.com/2009/06/asyncapi/dataload"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<sObject>
<Name>attachment1.gif</Name>
<ParentId>Account Id</ParentId>
<Body>#attachment1.gif</Body>
</sObject>
<sObject>
<Name>subdir/attachment2.doc</Name>
<ParentId>Account Id</ParentId>
<Body>#subdir/attachment2.doc</Body>
</sObject>
</sObjects>
Sample JSON request.txt File
This sample JSON file includes the same two records as the previous examples.
[
{
"Name" : "attachment1.gif",
"ParentId" : "Account Id",
"Body" : "#attachment1.gif"
},
{
"Name" : "subdir/attachment2.doc",
"ParentId" : "Account Id",
"Body" : "#subdir/attachment2.doc"
}
]