Using API, createSite method result with an error

Hello,

I’m following a guide on npm: netlify - npm
I want to create a new site using the API, I’m using nodejs as my server to handle all the request for
the API.
I’m facing a problem using createSite method, I keep getting an error:

JSONHTTPError: Unprocessable Entity
at parseResponse (C:\Users\Hadar LetsApp\Desktop\Hadar\netlify-api-test\test\node_modules\netlify\src\methods\response.js:13:11)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
at async callMethod (C:\Users\Hadar LetsApp\Desktop\Hadar\netlify-api-test\test\node_modules\netlify\src\methods\index.js:33:26)
at async C:\Users\Hadar LetsApp\Desktop\Hadar\netlify-api-test\test\routes\files.js:45:18 {
status: 422,
json: { errors: { subdomain: [Array] } }
}

Please let me know if you need more details about my code.

Best regards,
Hadar

hey @HadarLetsApp - any progress on this? we have been a bit understaffed, and generally don’t always have the capacity to debug people’s code, but i can leave this post open if you are still facing the issue - maybe someone has an idea we don’t!

Hey perry,
Thanks for the reply.

I’m still facing this issue but I stopped using netlify package.
Now I’m just sending an api request to https://api.netlify.com/api/v1.
My main goal is to set a custom domain name.
Any idea how to accomplish that?

Best regards,
Hadar

Hey @HadarLetsApp,
You should be able to use Netlify API documentation for that!

It’ll be a PATCH request with this JSON payload:

{
custom_domain: "example.com"
}

And in general, this is our best guide to using our API: [Support Guide] Understanding and using Netlify's API