Write

  • Writes item and property values.

  • Required security permission - WRITE.

  • HTTP methods supported: POST.

Description

Write can be performed to set the object value or object property for one or more items.

Parameters

Name Type Optional Description

write_fetch

string

yes

Defines how to read the value before writing. The possible values are: "OPC_READ_CACHE_BEFORE_WRITE" (the default value) "OPC_READ_DEVICE_BEFORE_WRITE" "OPC_READ_OBJECT_BEFORE_WRITE" "OPC_NO_READ_BEFORE_WRITE".

write_delay

integer

yes

Time to wait in order to collect multiple writes.

write_audit

boolean

yes

Create audit in system log for write operation, by default false.

write_timeo

integer

yes

Write timeout. Currently has no effect.

write_group

boolean

yea

Force OPC DA 2.05. Defines which OPC write method should be used. False(the default value) : OPC write uses the DA 3.0 write method(IOPCSyncIO2::WriteVQT). This allows to write value, quality and timestamp. True: OPC writes uses the DA 2.05 write method(IOPCSyncIO::Write). This allows to write value only. Some OPC Server do not support the DA 3.0 write method.

fields

string

yes

Comma separated string to customize which fields should be included in the response, by default 'i,p,v,q,t'. Provide 'ALL' to include all fields.

roe

boolean

yes

ReturnOnlyErrors, indicates the response should only contain item values for which the write operation failed, by default false.

insights

boolean

yes

Indicates application insights should be included in the response, by default false.

Examples

Write actual value

This example shows response of a write actual value request of a single or multiple objects or object properties.

Object properties like name, description, engineering unit, etc. have a unique path, an example of the object property Object Name is System/Core/Examples/Demo Data/Process Data/DC4711.ObjectName. Property path can be used the same way as a regular object path to read, write, create, modify, update or delete the property value.

HTTP POST

Request URL
  • /api/v2/write

Request body
{
  "items": [
    {
      "p": "/System/Core/Examples/Demo Data/Process Data/DC4711",
      "v": 10,
      "q": 0,
      "t": "2019-03-20T08:06:33.599Z"
    },
    {
      "p": "/System/Core/Examples/Demo Data/Process Data/DC666",
      "v": 99,
      "q": 2151415808,
      "t": "2019-03-20T08:06:33.599Z"
    }
  ]
}
Response body
{
  "items": [
    {
      "p": "/System/Core/Examples/Demo Data/Process Data/DC4711",
      "v": 10,
      "q": 0,
      "t": "2019-03-20T08:06:33.599Z"
    },
    {
      "p": "/System/Core/Examples/Demo Data/Process Data/DC666",
      "v": 99,
      "q": 2151415808,
      "t": "2019-03-20T08:06:33.599Z"
    }
  ]
}

Modify object properties

This example shows how to modify object name.

HTTP POST

Request URL
  • /api/v2/write

Request body
{
    "items": [
        {
            "p": "/System/Core/Examples/Demo Data/Process Data/DC4711.ObjectDescription",
            "v": "Test01"
        },
        {
            "p": "/System/Core/Examples/Demo Data/Process Data/DC666.OpcEngUnit",
            "v": "g/cm³"
        }
    ]
}
Response body
{
    "data": [
        {
            "i": 281474995716120,
            "p": "/System/Core/Examples/Demo Data/Process Data/DC4711.ObjectDescription",
            "t": null,
            "v": "Test01"
        },
        {
            "i": 281474995912728,
            "p": "/System/Core/Examples/Demo Data/Process Data/DC666.OpcEngUnit",
            "t": null,
            "v": "g/cm³"
        }
    ]
}

Write failure response

This example shows the response of a write request where setting the value of the second item failed due to an incorrect path. The HTTP status code of the response is in this example 200 (OK). The second item in the response contains an error object.

Response body

{
    "data": [
        {
            "i": 281474995716120,
            "p": "/System/Core/Examples/Demo Data/Process Data/DC4711.ObjectDescription",
            "t": null,
            "v": "Test01"
        },
        {
            "error": {
                "msg": "Object could not be resolved."
            },
            "p": "/System/Core/INVALID_PATH",
            "v": "g/cm³"
        }
    ]
}