I am trying to add a site route via the api with the following code:
from requests.auth import AuthBase
import requests
TOKEN = TOKEN
class TokenAuth(AuthBase):
def __init__(self, token):
self.token = token
def __call__(self, r):
# modify and return the request
r.headers['Authorization'] = f"Token {self.token}"
r.headers['Content-Type'] = "application/json"
return r
r = requests.post(f'https://my.opalstack.com/api/v0/site/add/',
auth=TokenAuth(TOKEN),
json={
"name": "sitename",
"domains": [{"id": "domainid",}],
"routes": [{"application": "appid","uri": "/",}],
"redirect": 'true',
"generate_le": 'true'
})
But I have not been successful and the only error response is: {"error": "request error."}
Any ideas? Thanks!
EDIT: I made some progress on this. Though it says not required, as I only have one server and one IP, those parameters seem to be necessary. And I do not believe the "redirect" option does anything when generating a new LE cert, as that has to be set after the cert is applied, just like through the dashboard.