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.

  1. Create an empty Mashup, save it and immediately close it.
  2. Re-open the Mashup, click the Design button and add a simple widget such as button.
  3. Clear the network tab history
  4. Click Save
  5. 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.
  6. Click view source link and Show more link at bottom of source view at the bottom of source text if it appears.
  7. 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: http://localhost:8080/Thingworx/Mashups/MashupName?reason=Mashup%20%3A%20design%20%3A%20updated%0A

You don’t need any other Query Params. Header key/value pairs that might need to be set:

X-Content-Type-Options: nosniff

X-XSS-Protection: 1;mode=block

Content-Security-Policy: frame-ancestors 'self'

X-Frame-Options: SAMEORIGIN

Content-Type: text/html;charset=UTF-8

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.

Thingworx Logo

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

Captcha loading...

This site uses Akismet to reduce spam. Learn how your comment data is processed.