Add
Adds a new object or updates an existing object.
Syntax
<Add type="ObjectType" attr_name1="attr_value1" attr_name2="attr_value2">
<ObjectType>
<property1>value1</property1>
<property2>value2</property2>
...
</ObjectType>
</Add>
Usage
Use the Add
command to add or update an object. The maximum number of objects you can add or update with one XML API call is 1,000
.
The Add
command cannot be used to add User
objects. Use CreateUser instead.
You can set custom field values as well as standard field values when adding objects. See Reading or Setting Custom Field Values Inline.
Attributes
Attribute |
Usage |
---|---|
|
XML API Only — Set the |
|
Use the
|
Arguments
Name |
Type |
Description |
---|---|---|
|
|
The object to add or update. |
Response
ObjectType
— The added or updated object with all properties including the object internal ID [id
], date created timestamp [created
], and date updated timestamp [updated
].
Sample Code — Upsert
The following example looks up a Category
object with name="XML-created category 1"
, updates the external ID of the matching Category
object, if it exists, or adds the object otherwise.
<Add type="Category" lookup="name">
<Category>
<name>XML-created category 1</name>
<externalid>111-2222</externalid>
</Category>
</Add>
Sample Code — Adding CV as Attachment to a Resource Profile
The following example adds a CV as attachment to an employee's resource profile. This is a two step process:
-
Add a
ResourceAttachment
object. -
Add the attachment file as base64 encoded data. Set the
ownerid
property of theAttachment
object to the internal ID of theResourceAttachment
object added in the previous step.
// Step 1 - Add a ResourceAttachment object
<Add type="ResourceAttachment">
<ResourceAttachment>
<type>CV</type>
<userid>123</userid>
</ResourceAttachment>
</Add>
// Step 2 - Upload the CV as Attachment with ownerid set to the
// internal ID of the ResourceAttachment object added in Step 1
<Add type="Attachment">
<Attachment>
<base64_data>U25lemth</base64_data>
<file_name>Collins_Marc_CV.txt</file_name>
<owner_type>ResourceAttachment</owner_type>
<ownerid>98765</ownerid>
</Attachment>
</Add>