Skip to content
Advertisement

Create domain ‘example.com’ failed Powerdns API

I always getting the same error (Create domain ‘example.com’ failed) (or any domain) when trying to create new DNS zone with Powerdns API call.

My request:

JavaScript

Similar api call to get a list of DNS zones is working. GET request work properly but not POST. Can anyone help, please?

My pdns.conf file is:

JavaScript

Maybe i have to change something in settings of my powerdns, idk really. I would be very grateful for any help!

Server response after POST request is 422 error (Unprocessable Entity)

HTTP/1.1 422 Unprocessable Entity Access-Control-Allow-Origin: * Connection: close Content-Length: 52 Content-Security-Policy: default-src ‘self’; style-src ‘self’ ‘unsafe-inline’ Content-Type: application/json Server: PowerDNS/4.4.1 X-Content-Type-Options: nosniff X-Frame-Options: deny X-Permitted-Cross-Domain-Policies: none X-Xss-Protection: 1; mode=block

JavaScript

Advertisement

Answer

Your code looks correct.

One big problem with your response.
Content-Length: 52
It should be Content-Length: 111.

I have been testing your code with two apps
One to send the curl request
One to receive it and respond with the request details.

Early on in my testing when I removed the Content-Type: application/json, I would see a content length of just over 50 bytes.

Below is my app. It gets 111 bytes.
If you change your curl url to http://eatled.com/receiveheader.php
You should get this:

JavaScript

LINK TO MY CURL SANDBOX

The source code:
sandbox.php

JavaScript

receiveheaders.php

JavaScript

END OF UPDATE



Add these two headers.

JavaScript

Right now the error you are getting is because the request content-type is

JavaScript

If use just used the content-type header and not accept, you’d get a different error. The API manual says you cannot use curl’s default Accept: */*

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement