Skip to content

Commit

Permalink
Merge pull request #500 from artoonie/clarify-rest-api
Browse files Browse the repository at this point in the history
fix trailing slash, clarify rest API docs
  • Loading branch information
artoonie authored Jul 23, 2024
2 parents 4ef7c89 + 9af73bf commit 39ccdf2
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions visualizer/tests/testRestApiExampleCode.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,8 @@ def test_update_visualization(self):
# In our tests, we are not hitting the real server.
# Your code will use https://www.rcvis.com as the live_server_url.
# To modify existing data, supply the visId
url = self.live_server_url + "/api/bp/" + str(visId)
# Note: the trailing slash is mandatory. Without it, it will fail silently.
url = self.live_server_url + "/api/bp/" + str(visId) + "/"

# API key should only be created as needed, and reused and kept secure
apiKey = self.get_api_key()
Expand All @@ -177,11 +178,13 @@ def test_update_visualization(self):

# Modify the data with a PATCH.
# PUT is also supported, but not shown here.
data = {'dataSourceURL': 'https://www.example.com/a/different/url'}
differentUrl = 'https://www.example.com/a/different/url'
data = {'dataSourceURL': differentUrl}

# POST the data to create a visualization
response = requests.post(url, data=data, headers=headers, timeout=3)
# PATCH to update
response = requests.patch(url, data=data, headers=headers, timeout=3)

# The response is the same as when you created the data, sans any changes you just made
# Verify the change succeeded
self.assertEqual(response.json()['slug'], 'favorite-ice-cream-flavors')
self.assertEqual(response.json()['id'], visId)
self.assertEqual(response.json()['dataSourceURL'], differentUrl)

0 comments on commit 39ccdf2

Please sign in to comment.