# Calling method on OPC UA server for file sending to a press

**URL:** <https://forum.inductiveautomation.com/t/calling-method-on-opc-ua-server-for-file-sending-to-a-press/54139>\
**Category:** Ignition\
**Created:** [December 15, 2021, 9:51am UTC](https://forum.inductiveautomation.com/t/calling-method-on-opc-ua-server-for-file-sending-to-a-press/54139 "2021-12-15T09:51:13Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![andrea.parola](https://avatars.discourse-cdn.com/v4/letter/a/b9e5f3/32.png) [@andrea.parola](https://forum.inductiveautomation.com/u/andrea.parola)\
**Post date:** [December 15, 2021, 9:51am UTC](https://forum.inductiveautomation.com/t/calling-method-on-opc-ua-server-for-file-sending-to-a-press/54139/1 "2021-12-15T09:51:13Z")

</div>

Hello,

I am trying to send the recipe file to an Arburg press. The connection is OPCUA and we have a method to call.  
It needs some flags and a file as a ByteString.

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/5/5/55a67fe34bb78a8857b7dbdeb95030d4c9730a8b.png)

I tried with UA expert and I am able to call the method and send the file.  
With Ignition I create a script that at the end calls  
file = open(filePath+fileName, “rb”)  
byte = file.read()  
digit=len(byte)  
file.close()

result = system.opcua.callMethod(  
“M028783”,  
“ns=2;i=399860”,  
“ns=2;i=399790”,  
[1, 1, 0, 0,byte]  
)

In this case I get an error like this one:  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/f/6/f66b002e6decdcdc7548e419f83578c1eee85c46.png)

I am assuming that the file I am passing is in the wrong format, but since is the same file I used with UA Expert, I think that I am reading the file in the wrong way.

Any idea on how to read the file in order to have a ByteString?

Many thanks  
Andrea

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [December 15, 2021, 12:56pm UTC](https://forum.inductiveautomation.com/t/calling-method-on-opc-ua-server-for-file-sending-to-a-press/54139/2 "2021-12-15T12:56:09Z")

</div>

What version of Ignition are you using? What is the type of the bytes argument you are passing to `callMethod`? I think just ints should work…

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [December 15, 2021, 1:08pm UTC](https://forum.inductiveautomation.com/t/calling-method-on-opc-ua-server-for-file-sending-to-a-press/54139/3 "2021-12-15T13:08:54Z")

</div>

Try using `system.file.readFileAsBytes` instead of opening the file in Jython, which just gives you a String value.

[https://docs.inductiveautomation.com/display/DOC81/system.file.readFileAsBytes](https://docs.inductiveautomation.com/display/DOC81/system.file.readFileAsBytes)

You need to be on a least Ignition 8.1.1 for this to work I think.

---

<div class="post-metadata">

**Author:** ![andrea.parola](https://avatars.discourse-cdn.com/v4/letter/a/b9e5f3/32.png) [@andrea.parola](https://forum.inductiveautomation.com/u/andrea.parola)\
**Post date:** [December 15, 2021, 1:57pm UTC](https://forum.inductiveautomation.com/t/calling-method-on-opc-ua-server-for-file-sending-to-a-press/54139/4 "2021-12-15T13:57:59Z")

</div>

At the moment we have 8.0.12, but in case we can try a test with an installation on a laptop and give it a try.
