Skip to content

Instantly share code, notes, and snippets.

@blankoworld
Created February 1, 2018 14:48
Show Gist options
  • Save blankoworld/dc43cac421a25e4b7cc3808c8624dc2c to your computer and use it in GitHub Desktop.
Save blankoworld/dc43cac421a25e4b7cc3808c8624dc2c to your computer and use it in GitHub Desktop.
#!/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