cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Need to share some code when posting a question or reply? Make sure to use the "Insert code sample" menu option. Learn more! X

Service REST Call Infotable Input Using XML

Ascherer17
14-Alexandrite

Service REST Call Infotable Input Using XML

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 5

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

Ascherer17
14-Alexandrite
(To:rosharma)

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

Both have returned 0.

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"}]}

Ascherer17
14-Alexandrite
(To:rosharma)

The person writing the REST call for our application is sending a XML body in the call.  I'm trying to provide the format that the REST call must be in.  The service I wrote (for testing) includes an Infotable input, but in the service I am unable to pull the data from the input infotable passed by the REST call.  My initial thought is that I am not formatting the infotable object correctly in the REST call body.

I have done it successfully using a JSON formatted call.  

i think infotable implicitly calls json format taking that dependent datashapes . the way i showed the content in last content.

if user wants to send XML then probably the input datatypes should be selected as XML at composer-then it shall work.

Top Tags