Created
February 1, 2018 14:48
-
-
Save blankoworld/dc43cac421a25e4b7cc3808c8624dc2c to your computer and use it in GitHub Desktop.
This file contains 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
#!/usr/bin/env python3 | |
import requests | |
import json | |
HEADERS = { | |
'Accept': 'application/json, text/plain, /', | |
'Content-Type': 'application/json' | |
} | |
# domain where API is installed | |
server = "quelquechose.domaine.tld" | |
PATH_API = '/'.join(["https:/", server, "api/v2/"]) | |
# place_type complete URL | |
place_type = "/".join([PATH_API, "place_types/"]) | |
# Create data to send | |
payload = { | |
'name': 'PlaceRESIF', | |
'type': "%s6" % place_type | |
} | |
try: | |
rs = requests.post( | |
PATH_API+"places/", | |
auth=('user','user'), | |
data = json.dumps(payload), | |
headers=HEADERS, | |
verify=False) | |
rs.raise_for_status() | |
except requests.exceptions.HTTPError as error: | |
print(error, '\n\t', rs.json()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment