Recreate Things with Code and HTTP Requests

Using the model schema JSON array mentioned in the previous section, you can utilize a POST HTTP request to create a new Thing with the same schema.

  1. Find the Model schema JSON array inside your Thing.
  2. Make a POST HTTP request to the following API endpoint (example in Python) and enter your model schema as the JSON payload:
    headers = {"Authorization": "Bearer " + token(fill with your access token)} response = requests.request("POST", ENDPOINT, headers=headers, json=body)
  3. Check if the HTTP response status code is 200/201 to verify that a new Thing has been created.
  4. Refresh AnythingDB on SmartWorks to see the new Thing created.
    Note: This is an example of what can be achieved using the model schema, and can be reprogrammed to fit any function. In this tutorial, it will be used in the Streamlit app to create a new ride Thing whenever a user presses a button.