Skip to main content
Ascherer17
16-Pearl
February 4, 2020
Question

Service REST Call Infotable Input Using XML

  • February 4, 2020
  • 5 replies
  • 2430 views

I cannot seem to figure out how to pass an infotable as an input to a Thingworx Service using a XML format REST call.  I am using Postman with an app key to call a Service on the platform using POST.  I am able to pass multiple other basetype inputs like strings, but the length of my infotable

My question is How exactly must the infotable be formatted to properly be sent to Thingworx?  When I try to get the length of the Infotable, it always gives me 0 rows.  

 

Here is an example REST call body that I have tried where the 'content-type' header is set to 'text/xml'.  The name of the service is 'TestXMLRest'.  There are 2 inputs: a string called 'StringInput' and a 2-row Infotable called 'MyInfoTableInput' using a datashape the contains 2 strings, 'Name' and 'PhoneNumber'.  

<TestXMLRest>
 <StringInput>Just a string</StringInput>
 <MyInfoTableInput>
 <DataShape>
 <FieldDefinitions>
 <FieldDefinition aspect.isPrimaryKey="false" baseType="STRING" description="" name="Name" ordinal="1"/>
 <FieldDefinition aspect.isPrimaryKey="false" baseType="STRING" description="" name="PhoneNumber" ordinal="2"/>
 </FieldDefinitions>
 </DataShape>
 <Rows>
 <Row>
 <Name>John</Name>
 <Phone>555-1111</Phone>
 </Row>
 <Row>
 <Name>Amy</Name>
 <Phone>555-5555</Phone>
 </Row>
 </Rows>
 </MyInfoTableInput>
</TestXMLRest>

 

5 replies

16-Pearl
February 4, 2020

how you are checking the length of infotable ? which function/snippet

Ascherer17
16-Pearl
February 4, 2020

I have tried both 'MyInfoTableInput.rows.length' and 'MyInfoTableInput.getRowCount().'

Both have returned 0.

16-Pearl
February 6, 2020

At my end i am able to call service with infotable input from postman 

 

In infotable input i am passing below format --- with this i am able to get rows in service -- that i verified through loggers.

i don't know why you are looking to send infotable as XML because infotable itself is a datatype for input that is been declared on service, so it is required to pass infotable only.

and if you want to pass XML as input then try using input datatype as XML in service ( which is also there in thingworx)

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

 

{"dataShape":{"fieldDefinitions":{"phone":{"name":"phone","aspects":{"isPrimaryKey":false},"description":"","baseType":"NUMBER","ordinal":2},"name":{"name":"name","aspects":{"isPrimaryKey":false},"description":"","baseType":"STRING","ordinal":1}}},"rows":[{"phone":"97112735","name":"raman"}]}