[Pdns-users] How to create zone via API?

Bino Oetomo wowon01 at gmail.com
Tue Apr 2 04:01:10 UTC 2024


Dear Otto.

Thankyou for your help.
I really appreciate it.

It works.
But I have problem with some TXT records.
I do all this stuf with python.
There is a record that python dictionary format like this :

```
{'content': '"v=DKIM1; k=rsa;
p=MIIBIjANBgDqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAu4rkPBK0diLB2v0PKvxS5BcIk2eo6MX2V0stJBqxJPq3wvKzQA0SHxeH0CQpDcrA9GoRDWQhv/dAKhnAFZ6ZAtEEYmQLGokyr3bHVw2QIByyRCgyhbO9OdeVvuAgoA+gyVrdZv76iK8P/JVjtBTcqhpkI/MPnXSmVSy+IOhxatFt/Dk/JLx2hdC73BoRCAnqJ"
"WiDZrgMLWE1LQi16TrOQYSWSkzbAMQW3ftnZPkLXcYIdT0haE5woU25r5D4tLLinJxe9ErZWDbOX1dzdNv+TK0HsNCO0ZT6mNa86yx/GLVmDq1V2b1azsDcQqpgCjUmrZ0fc2KiMbOEM8J5YqKVswIDAQAB;"',
'disabled': False}
```
when I test with python json.dumps, the result is:

```
{"content": "\\"v=DKIM1; k=rsa;
p=MIIBIjANBgDqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAu4rkPBK0diLB2v0PKvxS5BcIk2eo6MX2V0stJBqxJPq3wvKzQA0SHxeH0CQpDcrA9GoRDWQhv/dAKhnAFZ6ZAtEEYmQLGokyr3bHVw2QIByyRCgyhbO9OdeVvuAgoA+gyVrdZv76iK8P/JVjtBTcqhpkI/MPnXSmVSy+IOhxatFt/Dk/JLx2hdC73BoRCAnqJ\\"
\\"WiDZrgMLWE1LQi16TrOQYSWSkzbAMQW3ftnZPkLXcYIdT0haE5woU25r5D4tLLinJxe9ErZWDbOX1dzdNv+TK0HsNCO0ZT6mNa86yx/GLVmDq1V2b1azsDcQqpgCjUmrZ0fc2KiMbOEM8J5YqKVswIDAQAB;\\"",
"disabled": false}
```
It made the POST query fail. and also it failed when I test that json at
https://jsonlint.com/.

Currently, my work arround is just ignore all TXT records, and inject it
later using dnspython.

Sincerely
-bino-

when I do json.dumps and test resulted json in

On Tue, Apr 2, 2024 at 1:01 AM Otto Moerbeek <otto at drijf.net> wrote:

> On Mon, Apr 01, 2024 at 04:57:08PM +0700, Bino Oetomo via Pdns-users wrote:
>
> > Dear All.
> >
> > I'm trying to playing with PDNS API.
> >
> > I try to create new zone.
> >
> > The json payload is :
> > ```
> > {
> >     "name": "domain07.bino.",
> >     "kind": "Native",
> >     "records": [
> >         {
> >             "content": "ns1.cpaneldev.bino. emailserver.bino. 2024040101
> > 3600 1800 1209600 86400",
> >             "ttl": 86400,
> >             "name": "domain07.bino",
> >             "type": "SOA"
> >         }
> >     ],
> > }
> > ```
>
> A Zone object has no `records` member. It does have an `rrset` member,
> which is an array of rssets. See
> https://docs.powerdns.com/authoritative/http-api/zone.html#zone and
> https://docs.powerdns.com/authoritative/http-api/zone.html#rrset
>
>         -Otto
>
> >
> > I post it to 'http://127.0.0.1:9530/api/v1/servers/localhost/zones'
> > Got http status of 201.
> >
> > But when I check directly to mysql backend, I got :
> > ```
> > mysql> select * from records where domain_id = 41244;
> >
> +---------+-----------+---------------+------+-----------------------------------------------------------------------------------------------+------+------+----------+-----------+------+
> > | id      | domain_id | name          | type | content
> >                                                                   | ttl
> |
> > prio | disabled | ordername | auth |
> >
> +---------+-----------+---------------+------+-----------------------------------------------------------------------------------------------+------+------+----------+-----------+------+
> > | 1065344 |     41244 | domain07.bino | SOA  |
> > a.misconfigured.dns.server.invalid hostmaster.domain07.bino 2024040101
> > 10800 3600 604800 3600 | 3600 |    0 |        0 | NULL      |    1 |
> >
> +---------+-----------+---------------+------+-----------------------------------------------------------------------------------------------+------+------+----------+-----------+------+
> > 1 row in set (0,00 sec)
> >
> > ```
> >
> > Kindly please tell me how to prepare proper json payload to create zone
> via
> > pdns API
> >
> > regards
> > -bino-
>
> > _______________________________________________
> > Pdns-users mailing list
> > Pdns-users at mailman.powerdns.com
> > https://mailman.powerdns.com/mailman/listinfo/pdns-users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.powerdns.com/pipermail/pdns-users/attachments/20240402/eac24125/attachment.htm>


More information about the Pdns-users mailing list