# Unable to write values to the OPC UA server

**URL:** https://discourse.nodered.org/t/unable-to-write-values-to-the-opc-ua-server/79503
**Category:** General
**Created:** [30 June 2023 09:38 UTC](https://discourse.nodered.org/t/unable-to-write-values-to-the-opc-ua-server/79503 "2023-06-30T09:38:40Z")
**Posts on this page:** 1
**Showing post:** 6

<div class="post-metadata">

### Author: ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)
#### Post date: [30 June 2023 11:01 UTC](https://discourse.nodered.org/t/unable-to-write-values-to-the-opc-ua-server/79503/6 "2023-06-30T11:01:43Z")

</div>

> [@SK\_30](#):
>
> Following is my new code in function node.
> 
> ```auto
> msg.payload = {
> nodetype: 'inject',
> injectType: 'write',
> addressSpaceValues: 'ns=1;s=ExitStation',
> valuesToWrite: msg.payload
> }
> return msg;
> 
> ```
> 
> The write node requires the following data as input.
> 
> ```auto
> Input:
> payload (value to write one or all)
> topic
> addressSpaceItems or nodesToWrite (Array of Node-Ids)
> nodetype (inject)
> injectType (write)
> valuesToWrite (Array of values or objects to write individual)
> 
> ```

If the node needs the above ☝ format - why are you setting it up differently?

try...

```auto
msg.topic = ""
msg.nodetype ="inject"
msg.injectType = "write"
msg.addressSpaceItems = [
    {"name":"","nodeId":"ns=1;s=ExitStation","datatypeName":"Boolean"}
]
	
msg.valuesToWrite = [
    msg.payload
]
return msg;

```

Untested: this was formed from info in this post: [Issue with opcua and s7 -\> OPCServer in node red with many tags](https://discourse.nodered.org/t/issue-with-opcua-and-s7-opcserver-in-node-red-with-many-tags/58920)

* * *

Lastly, have you checked out the built in examples?

ctrl-i → `examples`

---

_[View the full topic](https://discourse.nodered.org/t/unable-to-write-values-to-the-opc-ua-server/79503)._
