Skip to main content
10-Marble
August 28, 2024
Question

How to validate service response

  • August 28, 2024
  • 1 reply
  • 1327 views

Hi, I have an extension which contain one service where data from csv file is loaded into an infotable and service return type is infotable. Service throws custom exception if anything fails or data is not valid in csv.  In thingworx, I am calling the extension service using a snippet service, now I need to validate the service response whether the response contains an infotable or is an error message returned from the service. Incase of error, I need to show it on mashup to end user. The issue is how to validate the response  whether its an infotable or an error message. Appreciate help in advance. 

1 reply

14-Alexandrite
August 29, 2024

@DeepakParihar I think the simplest approach would be to check if the response has rows [if(!!response.rows){.....}], if it has then is an infotable, if its a string other wise it would be the error message, If you are throwing an exception than you can wrap it around try catch and handle accrodingly. I am not sure if ThingWorx has anything native to check if it is a valid Infotable, may be you can check in snippets.

10-Marble
August 29, 2024

Hi @Bikash_Panda Thanks for your response. The return type of snippet service is an infotable and Validator does not accept infotable as an input. so how it is possible to validate the response.  

14-Alexandrite
September 3, 2024

Maybe you can use a Data Service Notification instead of a validator.  If your extension service returns an error, a notification message will pop up in the mashup.

 

Here's the help center link for adding notifications:

 

https://support.ptc.com/help/thingworx/platform/r9/en/index.html#page/ThingWorx/Help/Mashup_Builder/DataServicesandLinking/ServiceSuccessErrorNotification.html