Last active
August 17, 2018 14:58
-
-
Save DominikAngerer/63b8ad1bef656295c7e11b38fef0e959 to your computer and use it in GitHub Desktop.
Create a Space in Storyblok using Python and a Client structure
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import requests | |
| # Got from https://app.storyblok.com/#!/me/account (Personal access token) | |
| auth_token = 'YOUR_TOKEN' | |
| class Client: | |
| def __init__(self, auth_token): | |
| self.auth_token = auth_token | |
| def create_space(self, name, domain, parent='', dup=''): | |
| url = 'https://api.storyblok.com/v1/spaces' | |
| headers = { | |
| 'Authorization': self.auth_token | |
| } | |
| payload = { | |
| "space": { | |
| "name": name, | |
| "domain": domain, | |
| } | |
| } | |
| response = requests.post(url, json=payload, headers=headers) | |
| return response | |
| c = Client(auth_token) | |
| res = c.create_space("Space F", "http://example.storyblok.com") | |
| print(res.json()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment