Hello everyone,
I’m encountering a 422 Unprocessable Entity
error when using the Netlify API to create a new site. Here’s the code snippet I’m working with:
newSite, err := client.CreateSite(ctx, &models.SiteSetup{
Site: models.Site{
AccountSlug: "my slug",
Name: deployment.Netlify,
CustomDomain: fmt.Sprintf("%s.app.mdfriday.com", deployment.Domain),
Ssl: true,
},
}, true) // Setting configureDNS to true
The Issue
Each time I call CreateSite
, I get a 422 Unprocessable Entity
error. I’ve verified that AccountName
and AccountSlug
are valid, and CustomDomain
appears to follow the correct format (for example, example.app.mdfriday.com
). I set Ssl: true
to enable HTTPS and configured configureDNS
as true
.
What I’ve Tried
- Removing the
Ssl
field, but the error persists. - Only setting the
Name
field, withoutCustomDomain
or any additional fields, but still encountering the same error. - Confirming that all parameters align with the API documentation.
Questions
- Could the
422
error be related to theSsl
orCustomDomain
fields? - Are there any specific requirements for creating a site that might not be immediately apparent in the documentation?
- Does
configureDNS
set totrue
require any other conditions or dependencies?
Thanks in advance for any guidance or advice you can offer!