Skip to main content
12-Amethyst
September 5, 2024
Solved

Infotable Query via RestAPI

  • September 5, 2024
  • 2 replies
  • 2068 views

Hello

 

I am currently looking for a way to dynamically filter an info table via a service using a query via RestAPI.

Ideally, the full functionality of the query function should be retained. Has anyone had any experience with this?

In SAP IoT, the whole thing is more or less solved as a complete parameter in the URL. But in Thingworx, this doesn't seem to be possible, or am I missing something?

 

Thanks in advance

Best answer by VladimirRosu_116627

Try to pass it as a parameter first and see if it works (use a simpler service with a number first to see if this approach works).

For as long as I remember, the service input parameters have been passed in the body, but tbh I never tried on my end to pass them as URL params - hence the recommendation.

2 replies

Rocko
19-Tanzanite
September 5, 2024

Can you give an example of your code?

12-Amethyst
September 5, 2024

Unfortunately, I am not allowed to share internal code and would have to create a general snippet first.

 

But I don't really understand why you need one:

The question is very general how I can best use an info table query/filter via RestCall by passing it in the URL or as a parameter in the header

Rocko
19-Tanzanite
September 5, 2024
It's just unclear to me what you mean by "Infotable query filter"

19-Tanzanite
September 6, 2024

While I'm not sure I understand 100% the situation, the Query snippet allows you to query an Infotable:

let params = {
	t: undefined /* INFOTABLE */,
	query: undefined /* QUERY */
};

// result: INFOTABLE
let result = Resources["InfoTableFunctions"].Query(params);

 This is user-callable via POST REST, just like any other ThingWorx API (except the Websocket endpoints).

The parameters should be sent in the body of the request - I don't remember if you can pass them as URL parameters.

12-Amethyst
September 6, 2024

Hey Vladimir,

 

Yeah thats actualy what i was trying to do via URL oder as a Parameter. in Postman. So its only possible in the body?

Best regards.

19-Tanzanite
September 6, 2024

Try to pass it as a parameter first and see if it works (use a simpler service with a number first to see if this approach works).

For as long as I remember, the service input parameters have been passed in the body, but tbh I never tried on my end to pass them as URL params - hence the recommendation.