fix: ionos API content-type

This commit is contained in:
2024-12-23 14:13:18 +01:00
parent 3c8b6ef264
commit 9478149a20

View File

@@ -83,6 +83,8 @@ func (i *IonosAPIImpl) HttpCall(method string, url string, body io.Reader) (*htt
}
req.Header.Add("X-API-Key", i.APIKey)
req.Header.Add("Content-Type", "application/json")
req.Header.Add("Accept", "application/json")
return i.HTTPClient.Do(req)
}
@@ -121,10 +123,10 @@ func (i *IonosAPIImpl) GetRecordId(zoneId string, tld string, subdomain string,
json.Unmarshal(responseBody, &zone)
var domain string
if subdomain != "" {
domain = subdomain + "." + tld
} else {
if subdomain == "@" || subdomain == "" {
domain = tld
} else {
domain = subdomain + "." + tld
}
for _, record := range zone.Records {
@@ -162,12 +164,14 @@ func (i *IonosAPIImpl) SetARecord(tld string, subdomain string, ip net.IP, ttl i
return nil, err
}
responseBody := make([]byte, res.ContentLength)
res.Body.Read(responseBody)
if res.StatusCode != 200 {
return nil, errors.New("error updating record")
}
responseBody := make([]byte, res.ContentLength)
res.Body.Read(responseBody)
changeRecord := ChangeRecord{}
json.Unmarshal(responseBody, &changeRecord)