Upgrade a Custom Task Using Windchill Swagger Connector
Follow these steps to upgrade your custom task to use Windchill Swagger connector (ptc-windchill-integration-connector).
1. Either use the out-of-the-box connector ptc-windchill-integration-connector, or create your own connector and use WindchillSwaggerConnector as the Thing Template. When upgrading, we recommend that you duplicate the out-of-the-box connector ptc-windchill-integration-connector and customize the duplicated connector. Otherwise, you’ll lose your own customized connector.
2. Create a service for the operationType and the URL that are used in the processJSONRequest API calls on the connector.
If you need more information on creating services, start with the
ThingWorx Help topic
Thing Services.
3. In the service, list all queryParams as in earlier versions of ThingWorx Navigate. Make sure that your param names exactly match the names expected by the service.
4. If you have POST requests, add these items to the queryParams section:
a. CSRF token. To get a token, execute the service on the connector Security_Get_CSRF.
b. Data (JSONObject) param. In previous releases, this was a separate param in the processJSONRequest calls.
5. Make sure the connector is a Thing that can be identified by name:
Thing connector = (Thing)EntityUtilities.findEntity(connector,ThingworxRelationshipTypes.Thing);
6. Start the service on the connector Thing:
InfoTable serviceResult = connector.processServiceRequest(serviceName,params);
7. Use WindchillServicesConnector.InvokeService(operationType,serviceName,queryParams) as a reference and util API for use in any custom APIs or tasks.