API: fail to update config with text/caddyfile
tetra12 opened this issue · comments
tetra12 commented
I'm trying to programmatically update caddy
with a simple http
call with a caddyfile
as per docs.
Getting 400
for the text/caddyfile
data type:
res, err := s.httpClient.Post(s.cfg.AdminURL, "text/caddyfile", byteBuffer)
if err != nil {
return err
}
ERROR admin.api request error {"error": "unacceptable content-type: text/caddyfile; 'application/json' required", "status_code": 400}
Config works fine for the application/json
type.
Caddy: v2.7.6 (master)
Go: 1.22.0
OS: Ubuntu 22.04
Francis Lavoie commented
What's s.cfg.AdminURL
set to? You should use the /load
endpoint: https://caddyserver.com/docs/api#post-load
tetra12 commented
@francislavoie Yes, used an invalid URL. Thanks for spotting out 👍