Every time I send the POST query to the Server, it complains that it doesn’t support GET:
headers = {
"accept": "application/json",
"Content-Type": "application/json",
"Authorization": f"Token {token}",
"X-CSRFToken": token
}
base_url = 'https://my.opalstack.com/api/v1/'
def parse_response(response):
if response:
print(response.json())
else:
print(response.text)
def send_post(url, data):
print("But it's POST")
parse_response(requests.post(url, json=data, headers=headers))
def send_get(url, params = None):
parse_response(requests.get(url, params=params, headers=headers))
def add_domain(name):
data = [{ 'name': name }]
send_post(base_url + 'domain/create', data)
add_domain('mydomain.com')
But it's POST
{"detail":"Method \"GET\" not allowed."}