# Proper XML CALL

**URL:** https://forum.opennebula.io/t/proper-xml-call/7510
**Category:** Product Support
**Created:** [July 31, 2019, 3:53pm UTC](https://forum.opennebula.io/t/proper-xml-call/7510 "2019-07-31T15:53:03Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Leonid](https://avatars.discourse-cdn.com/v4/letter/l/d9b06d/32.png) [@Leonid](https://forum.opennebula.io/u/Leonid)
#### Post date: [July 31, 2019, 3:53pm UTC](https://forum.opennebula.io/t/proper-xml-call/7510/1 "2019-07-31T15:53:03Z")

</div>

Hi guys,

We are trying to create a VM template with one.template.allocate API call:

```
> curl -H "Content-Type: text/xml" -X POST \
> -d "<?xml version='1.0'?>
> <methodCall>
> <methodName>one.template.allocate</methodName>
> <params>
> <param>
> <value><string>oneadmin:oneadmin</string></value>
> </param>
> <param>
> <value><string><NAME>abc</NAME></string></value>
> </param>
> </params>
> </methodCall>" http://vip_ip:2633/RPC2

```

But get an error:

Call XML not a proper XML-RPC call. The child of a \<value\> element is neither \<array\> nor \<struct\>, but has 1 child elements of its own.

Please help in advice!

---

<div class="post-metadata">

### Author: ![atodorov\_storpool](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.opennebula.io/atodorov_storpool/32/5327_2.png) [@atodorov\_storpool](https://forum.opennebula.io/u/atodorov_storpool)
#### Post date: [July 31, 2019, 9:00pm UTC](https://forum.opennebula.io/t/proper-xml-call/7510/2 "2019-07-31T21:00:40Z")

</div>

Hi Leonid,

Following [XML-RPC API doc](http://docs.opennebula.org/5.8/integration/system_interfaces/api.html#xml-rpc-api) you should encapsulate the values in `<TEMPLATE> ... </TEMPLATE>` . And the [XML-RPC spec](http://xmlrpc.scripting.com/spec.html) update **Updated 1/21/99 DW** says:

> What characters are allowed in strings? Non-printable characters? Null characters? Can a “string” be used to hold an arbitrary chunk of binary data?
> 
> Any characters are allowed in a string except \< and &, which are encoded as &lt; and &amp;. A string can be used to encode binary data.

This is the academic approach to the solution. The practical one that I usually use is to run `mitmproxy` and run the shell tools with endpoint the proxied port

```auto
#run in one terminal
mitmproxy --mode reverse:http://127.0.0.1:2633 -p 2634
#and in a second terminal call onetemplate...
cat >template.xml <<EOF
<TEMPLATE>
  <NAME>test</NAME>
</TEMPLATE>
EOF
onetemplate create template.xml --endpoint http://127.0.0.1:2634/RPC2
ID: 20

```

After getting familiar with the interface of `mitmproxy` You could monitor the actual XML-RPC2 API request, which is as follow:

```
<?xml version="1.0" ?>
<methodCall>
  <methodName>one.template.allocate</methodName>
  <params>
    <param>
    <value>
      <string>oneadmin:oneadmin</string>
    </value>
    </param>
    <param>
    <value>
      <string>
        &lt;TEMPLATE&gt;
          &lt;NAME&gt;test4&lt;/NAME&gt;
        &lt;/TEMPLATE&gt;
      </string>
    </value>
    </param>
  </params>
</methodCall>

```

Hope this helps. 😉

Best Regards,  
Anton Todorov

---

<div class="post-metadata">

### Author: ![Leonid](https://avatars.discourse-cdn.com/v4/letter/l/d9b06d/32.png) [@Leonid](https://forum.opennebula.io/u/Leonid)
#### Post date: [August 1, 2019, 4:25pm UTC](https://forum.opennebula.io/t/proper-xml-call/7510/3 "2019-08-01T16:25:29Z")

</div>

Hi Anton,

Thank you very much !!  
That is exactly what we need.
