Agent.SetCustomField
  • 25 May 2021
  • 1 Minute to read
  • Contributors
  • Dark
    Light
  • PDF

Agent.SetCustomField

  • Dark
    Light
  • PDF

Article Summary

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.

NameRequiredTypeDescription
AgentIDTruestringAgent ID number.
CustomFieldNameTruestringName of the custom field.
CustomFieldValueFalsestringValue 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

NameRequiredTypeDescription
FileFalseXMLA 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

NameRequiredTypeDescription
POSTDATAFalseJSONJSON 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

NameTypeDescription
ResultstringSuccess if the operation was successful.
AgentIDstringAgent ID number.
<FieldName>*stringThe 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?

What's Next