VMware Cloud Community
LuckyT
Contributor
Contributor

xml parsing error

Hi All,

          I'm trying to deploy vshield edge using HTTP REST operation. I'm able to deploy Edge, if i POST the whole XML directly to Invoke REST Operation workflow. But if i try to generate XML from String in Scriptable task and then pass that xml to Invoke REST Operation workflow, it fails with below error:

Error:

[2013-10-19 16:54:44.541] [I] Content as string: <?xml version="1.0" encoding="UTF-8"?>

<error><details>Invalid token character &apos;<&apos; in token &quot;<edge> <datacenterMoid>datacenter-2<&quot;</details><errorCode>100</errorCode></error>

[2013-10-19 16:54:44.581] [I] HTTPError: status code: 500 (Workflow:Invoke a REST operation / Check status code (item3)#1)

Script in Scriptable task:

var xmlContent = <edge></edge>;

xmlContent.datacenterMoid = datacenter_id;

xmlContent.name = vshield_name;

xmlContent.fqdn = vshield_name;

xmlContent.appliances.applianceSize = applianceSize1;

xmlContent.appliances.appliance.resourcePoolId = resourcePool_Id;

xmlContent.appliances.appliance.datastoreId = datastore_Id;

xmlContent.vnics.vnic.index=0;

xmlContent.vnics.vnic.name="internal0";

xmlContent.vnics.vnic.type="INTERNAL";

xmlContent.vnics.vnic.portgroupId=dvportgroup_nic1;

xmlContent.vnics.vnic.addressGroups.addressGroup.primaryAddress=ipAddress_nic1;

xmlContent.vnics.vnic.addressGroups.addressGroup.secondaryAddresses.ipAddress="192.168.3.2";

xmlContent.vnics.vnic.addressGroups.addressGroup.subnetMask="255.255.255.0";

xmlContent.cliSettings.userName=vSMUsername;

xmlContent.cliSettings.password=password1;

xmlContent.cliSettings.remoteAccess=true;

xmlContent.autoConfiguration.enabled=true;

xmlContent.autoConfiguration.rulePriority="high";

content = String(xmlContent);

Output XML:

<edge>

  <datacenterMoid>datacenter-2</datacenterMoid>

  <name>my_shield</name>

  <fqdn>my_shield</fqdn>

  <appliances>

    <applianceSize>compact</applianceSize>

    <appliance>

      <resourcePoolId>resgroup-121</resourcePoolId>

      <datastoreId>datastore-44</datastoreId>

    </appliance>

  </appliances>

  <vnics>

    <vnic>

      <index>0</index>

      <name>internal0</name>

      <type>INTERNAL</type>

      <portgroupId>datacenter-2</portgroupId>

      <addressGroups>

        <addressGroup>

          <primaryAddress>192.168.3.1</primaryAddress>

          <secondaryAddresses>

            <ipAddress>192.168.3.2</ipAddress>

          </secondaryAddresses>

          <subnetMask>255.255.255.0</subnetMask>

        </addressGroup>

      </addressGroups>

    </vnic>

  </vnics>

  <cliSettings>

    <userName>admin</userName>

    <password>pass</password>

    <remoteAccess>true</remoteAccess>

  </cliSettings>

  <autoConfiguration>

    <enabled>true</enabled>

    <rulePriority>high</rulePriority>

  </autoConfiguration>

</edge>

Thanks in advance.

Reply
0 Kudos
5 Replies
Ethan44
Enthusiast
Enthusiast

Hi

Welcome to the communities.

Invalid token means I assume some thing security or credentil probloem

  

"I never look back, it distracts me from the now"
Reply
0 Kudos
LuckyT
Contributor
Contributor

I checked i could not find any security or credential problem. Can anyone suggest me?

Reply
0 Kudos
iiliev
VMware Employee
VMware Employee

'Invalid token character' error is not security related.

Most likely, it means the XML document content you are passing is not valid/well-formed; ie. something is not escaped properly.

Reply
0 Kudos
LuckyT
Contributor
Contributor

In my previous post i have copied the XML, which doesn't have any error. Can you look into and help?

Reply
0 Kudos
LuckyT
Contributor
Contributor

Thanks to all. Finally it got resolved. There was some special character getting included.

Reply
0 Kudos