Add a Mashup to Thingworx via REST
Why would you do this?
You can use REST to generate and update mashups based on data once you understand the data structure and vocabulary of mashups and widgets.
You will need access to a Thingworx Instance. You can find hosted trial instances on PTC’s Thingworx learning site.
- Create an empty Mashup, save it and immediately close it.
- Re-open the Mashup, click the Design button and add a simple widget such as button.
- Clear the network tab history
- Click Save
- Find the request URL (usually it will be the top entry on the XHR list) and scroll down to request payload on the Right of the network history.
- Click view source link and Show more link at bottom of source view at the bottom of source text if it appears.
- Copy the whole thing.
Use browser Dev tools Network tab to get the header and body of a request to save an existing Mashup.
Use Postman to create a PUT request. Here is an example request URL:
You don’t need any other Query Params. Header key/value pairs that might need to be set:
Content-Security-Policy: frame-ancestors 'self'
You can use basic Auth, but you will need to set the PlatformSubsystem configuration Allow Request Method Switch to true to allow REST calls with it. This is more convenient than setting up application keys, but not for production due to security concerns
Click the Body tab in Postman, click raw radio button, and then Paste the request body that was copied from the network tab source view.
Send the new request.