Agent.SetCustomField
- 25 May 2021
- 1 Minute to read
- Contributors
- Print
- DarkLight
- PDF
Agent.SetCustomField
- Updated on 25 May 2021
- 1 Minute to read
- Contributors
- Print
- DarkLight
- PDF
Article Summary
Share feedback
Thanks for sharing your feedback!
Description
Set a custom field to a value on a specified agent.
URL parameters
URL parameter ordering
The URL parameters below are listed in the order they should be entered in the API URL.
Name | Required | Type | Description |
---|---|---|---|
AgentID | True | string | Agent ID number. |
CustomFieldName | True | string | Name of the custom field. |
CustomFieldValue | False | string | Value for the custom field. If excluded, the value will return to the default value for the account. |
Request body (optional)
The agents and values of the custom field you want to edit in bulk. You can format these in XML or JSON.
Custom Field Bulk Edit
When updating in bulk you still must specify the single custom field you are working with but can specify multiple AgentID
's and different values.
XML
Name | Required | Type | Description |
---|---|---|---|
File | False | XML | A file containing the agents with values for the custom field. POST using Content-Type multipart/form-data . |
<ItemList>
<Item>
<AgentID>1005</AgentID>
<Value>asd</Value>
</Item>
<Item>
<AgentID>1006</AgentID>
<Value>Vasd</Value>
</Item>
<Item>
<AgentID>1004</AgentID>
<Value>Value4</Value>
</Item>
</ItemList>
JSON
Name | Required | Type | Description |
---|---|---|---|
POSTDATA | False | JSON | JSON array of agents with values for the custom field. POST using Content-Type application/x-www-form-urlencoded . |
[
{ "AgentID": "1002", "value": "update2" },
{ "AgentID": "1003", "Value": "update3" },
{ "AgentID": "1004", "Value": "update4" },
{ "AgentID": "1005", "Value": "update5" }
]
Responses
Name | Type | Description |
---|---|---|
Result | string | Success if the operation was successful. |
AgentID | string | Agent ID number. |
<FieldName> * | string | The set value for the field. |
*When the user sends a bulk request, it will return an ItemList with each AgentID
and <FieldName>
.
Sample requests
GET
with agent, custom field and value specified in the URL
curl -X GET 'https://api.mozenda.com/rest?WebServiceKey=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX&Service=Mozenda10&Operation=Agent.SetCustomField&AgentID=1022&CustomFieldName=TestBoy&CustomFieldValue=test'
POST
- XML body
curl -X POST 'https://api.mozenda.com/rest?WebServiceKey=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX&Service=Mozenda10&Operation=Agent.SetCustomField&CustomFieldName=TestBoy'
-F 'file=@/path/to/file.xml'
POST
- JSON body
curl -X POST 'https://api.mozenda.com/rest?WebServiceKey=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX&Service=Mozenda10&Operation=Agent.SetCustomField&CustomFieldName=TestBoy'''
-d '[ { "AgentID": "1002", "value": "update2" }, { "AgentID": "1003", "Value": "update3" }]'
Sample responses
XML
<?xml version="1.0" encoding="utf-8"?>
<AgentSetCustomFieldResponse xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Result>Success</Result>
<ItemList>
<Item>
<AgentID>1002</AgentID>
<myfield>update2</myfield>
</Item>
<Item>
<AgentID>1003</AgentID>
<myfield>update3</myfield>
</Item>
<Item>
<AgentID>1004</AgentID>
<myfield>update4</myfield>
</Item>
<Item>
<AgentID>1005</AgentID>
<myfield>update5</myfield>
</Item>
</ItemList>
</AgentSetCustomFieldResponse>
JSON (add &ResponseFormat=JSON
)
{
"AgentID":1022,
"TestBoy":"test",
"JsonResult":{
"Command":"Agent.SetCustomField",
"AutoLoggedIn":false,
"WebConsoleKey":"",
"Result":"Success",
"ErrorCode":"",
"ErrorDescription":"",
"ErrorList":[
],
"ExecutionTime":{
"Ticks":0,
"Days":0,
"Hours":0,
"Milliseconds":0,
"Minutes":0,
"Seconds":0,
"TotalDays":0,
"TotalHours":0,
"TotalMilliseconds":0,
"TotalMinutes":0,
"TotalSeconds":0
}
}
}
Was this article helpful?