<div><br></div><div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Jun 30, 2020 at 08:52 Tomasz Chmielewski via Pdns-users <<a href="mailto:pdns-users@mailman.powerdns.com">pdns-users@mailman.powerdns.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;padding-left:1ex;border-left-color:rgb(204,204,204)">Unfortunately I'm not able to find what I'm doing wrong.<br>
<br>
The error is returned no matter if I have "master=yes" set in pdns.conf <br>
or not, and no matter if I use "masters": [] or not.</blockquote><div dir="auto"><br></div><div dir="auto">Take a look at the object properties description at the bottom of the documentation that Frank linked you. The documentation I know doesn't include an example for zone creation. You're missing the type key. I don't think that there are any other issues with the post data you're sending. Just missing the type.</div><div dir="auto"><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;padding-left:1ex;border-left-color:rgb(204,204,204)"><br>
<br>
The query I'm sending:<br>
<br>
# curl --data '{"name":"<a href="http://example.org" rel="noreferrer" target="_blank">example.org</a>.", "kind": "Native", "nameservers": <br>
["<a href="http://ns1.example.org" rel="noreferrer" target="_blank">ns1.example.org</a>.", "<a href="http://ns2.example.org" rel="noreferrer" target="_blank">ns2.example.org</a>."]}' -v -H 'X-API-Key: my-api-key' <br>
<a href="http://10.58.150.164:8081/api/v1/servers/localhost/zones" rel="noreferrer" target="_blank">http://10.58.150.164:8081/api/v1/servers/localhost/zones</a><br>
*   Trying 10.58.150.164:8081...<br>
* TCP_NODELAY set<br>
* Connected to 10.58.150.164 (10.58.150.164) port 8081 (#0)<br>
> POST /api/v1/servers/localhost/zones HTTP/1.1<br>
> Host: <a href="http://10.58.150.164:8081" rel="noreferrer" target="_blank">10.58.150.164:8081</a><br>
> User-Agent: curl/7.68.0<br>
> Accept: */*<br>
> X-API-Key: my-api-key<br>
> Content-Length: 98<br>
> Content-Type: application/x-www-form-urlencoded<br>
> <br>
* upload completely sent off: 98 out of 98 bytes<br>
* Mark bundle as not supporting multiuse<br>
< HTTP/1.1 422 Unprocessable Entity<br>
< Access-Control-Allow-Origin: *<br>
< Connection: close<br>
< Content-Length: 50<br>
< Content-Security-Policy: default-src 'self'; style-src 'self' <br>
'unsafe-inline'<br>
< Content-Type: application/json<br>
< Server: PowerDNS/4.2.1<br>
< X-Content-Type-Options: nosniff<br>
< X-Frame-Options: deny<br>
< X-Permitted-Cross-Domain-Policies: none<br>
< X-Xss-Protection: 1; mode=block<br>
<<br>
* Closing connection 0<br>
{"error": "Creating domain '<a href="http://example.org" rel="noreferrer" target="_blank">example.org</a>.' failed"}<br>
<br>
<br>
<br>
Tomasz<br>
<br>
<br>
On 2020-06-30 22:38, Frank Louwers wrote:<br>
> Please find the docs for 4.2.x at<br>
> <a href="https://docs.powerdns.com/authoritative/http-api/index.html#endpoints-and-objects-in-the-api" rel="noreferrer" target="_blank">https://docs.powerdns.com/authoritative/http-api/index.html#endpoints-and-objects-in-the-api</a><br>
> <br>
> In particular, note that the "masters" string must only be set if the<br>
> type is Slave.<br>
> <br>
> Regards,<br>
> <br>
> Frank<br>
> <br>
> On 30 Jun 2020, at 15:20, Tomasz Chmielewski <<a href="mailto:mangoo@wpkg.org" target="_blank">mangoo@wpkg.org</a>> wrote:<br>
> <br>
>> I'm using pdns 4.2.1.<br>
>> <br>
>> Tomasz<br>
>> <br>
>> On 2020-06-30 22:17, Frank Louwers wrote:<br>
>> Hi Tomasz,<br>
>> What version are you using? The docs you mention, refer to an old<br>
>> version of PowerDNS Auth...<br>
>> Frank<br>
>> On 30 Jun 2020, at 15:09, Tomasz Chmielewski via Pdns-users<br>
>> <<a href="mailto:pdns-users@mailman.powerdns.com" target="_blank">pdns-users@mailman.powerdns.com</a>> wrote:<br>
>> I did it exactly as in PowerDNS README:<br>
>> <a href="https://doc.powerdns.com/md/httpapi/README/" rel="noreferrer" target="_blank">https://doc.powerdns.com/md/httpapi/README/</a><br>
>> Does it mean README is buggy?<br>
>> But it also fails without "masters" attribute:<br>
>> # echo '{"name":"<a href="http://example.org" rel="noreferrer" target="_blank">example.org</a> [1].", "kind": "Native", "nameservers":<br>
>> ["<a href="http://ns1.example.org" rel="noreferrer" target="_blank">ns1.example.org</a> [2].", "<a href="http://ns2.example.org" rel="noreferrer" target="_blank">ns2.example.org</a> [3]."]}' | jq<br>
>> {<br>
>> "name": "<a href="http://example.org" rel="noreferrer" target="_blank">example.org</a> [1].",<br>
>> "kind": "Native",<br>
>> "nameservers": [<br>
>> "<a href="http://ns1.example.org" rel="noreferrer" target="_blank">ns1.example.org</a> [2].",<br>
>> "<a href="http://ns2.example.org" rel="noreferrer" target="_blank">ns2.example.org</a> [3]."<br>
>> ]<br>
>> }<br>
>> Tomasz<br>
>> On 2020-06-14 23:52, Kevin P. Fleming via Pdns-users wrote:<br>
>> Have you doing this without specifying the 'masters' attribute at<br>
>> all?<br>
>> Native zones don't support masters, so it's possible that supplying<br>
>> the attribute, even with an empty list, is causing a failure.<br>
>> On Sun, Jun 14, 2020 at 9:29 AM Tomasz Chmielewski via Pdns-users<br>
>> <<a href="mailto:pdns-users@mailman.powerdns.com" target="_blank">pdns-users@mailman.powerdns.com</a>> wrote:<br>
>> Using 4.2.1, I'm getting "HTTP/1.1 422 Unprocessable Entity" when<br>
>> trying<br>
>> to create a zone as described on<br>
>> <a href="https://doc.powerdns.com/md/httpapi/README/" rel="noreferrer" target="_blank">https://doc.powerdns.com/md/httpapi/README/</a><br>
>> What am I doing wrong?<br>
>> '{"name":"<a href="http://example.org" rel="noreferrer" target="_blank">example.org</a>.", "kind": "Native", "masters": [],<br>
>> "nameservers":<br>
>> ["<a href="http://ns1.example.org" rel="noreferrer" target="_blank">ns1.example.org</a>.", "<a href="http://ns2.example.org" rel="noreferrer" target="_blank">ns2.example.org</a>."]}' validates fine with jq:<br>
>> # echo '{"name":"<a href="http://example.org" rel="noreferrer" target="_blank">example.org</a>.", "kind": "Native", "masters": [],<br>
>> "nameservers": ["<a href="http://ns1.example.org" rel="noreferrer" target="_blank">ns1.example.org</a>.", "<a href="http://ns2.example.org" rel="noreferrer" target="_blank">ns2.example.org</a>."]}' | jq<br>
>> {<br>
>> "name": "<a href="http://example.org" rel="noreferrer" target="_blank">example.org</a>.",<br>
>> "kind": "Native",<br>
>> "masters": [],<br>
>> "nameservers": [<br>
>> "<a href="http://ns1.example.org" rel="noreferrer" target="_blank">ns1.example.org</a>.",<br>
>> "<a href="http://ns2.example.org" rel="noreferrer" target="_blank">ns2.example.org</a>."<br>
>> ]<br>
>> }<br>
>> # curl -X POST --data '{"name":"<a href="http://example.org" rel="noreferrer" target="_blank">example.org</a>.", "kind": "Native",<br>
>> "masters": [], "nameservers": ["<a href="http://ns1.example.org" rel="noreferrer" target="_blank">ns1.example.org</a>.",<br>
>> "<a href="http://ns2.example.org" rel="noreferrer" target="_blank">ns2.example.org</a>."]}'<br>
>> -v -H 'X-API-Key: my-key'<br>
>> <a href="http://10.58.150.164:8081/api/v1/servers/localhost/zones" rel="noreferrer" target="_blank">http://10.58.150.164:8081/api/v1/servers/localhost/zones</a><br>
>> Note: Unnecessary use of -X or --request, POST is already inferred.<br>
>> *   Trying 10.58.150.164:8081...<br>
>> * TCP_NODELAY set<br>
>> * Connected to 10.58.150.164 (10.58.150.164) port 8081 (#0)<br>
>> POST /api/v1/servers/localhost/zones HTTP/1.1<br>
>> Host: <a href="http://10.58.150.164:8081" rel="noreferrer" target="_blank">10.58.150.164:8081</a><br>
>> User-Agent: curl/7.68.0<br>
>> Accept: */*<br>
>> X-API-Key: my-key<br>
>> Content-Length: 113<br>
>> Content-Type: application/x-www-form-urlencoded<br>
>> * upload completely sent off: 113 out of 113 bytes<br>
>> * Mark bundle as not supporting multiuse<br>
>> < HTTP/1.1 422 Unprocessable Entity<br>
>> < Access-Control-Allow-Origin: *<br>
>> < Connection: close<br>
>> < Content-Length: 50<br>
>> < Content-Security-Policy: default-src 'self'; style-src 'self'<br>
>> 'unsafe-inline'<br>
>> < Content-Type: application/json<br>
>> < Server: PowerDNS/4.2.1<br>
>> < X-Content-Type-Options: nosniff<br>
>> < X-Frame-Options: deny<br>
>> < X-Permitted-Cross-Domain-Policies: none<br>
>> < X-Xss-Protection: 1; mode=block<br>
>> <<br>
>> * Closing connection 0<br>
>> {"error": "Creating domain '<a href="http://example.org" rel="noreferrer" target="_blank">example.org</a>.' failed"}<br>
>> This logs:<br>
>> Jun 14 13:19:59 dns1 pdns_server[25635]: [webserver]<br>
>> a5b403b9-83a9-45b9-a638-0f2b4ce1f4d8 Request details:<br>
>> Jun 14 13:19:59 dns1 pdns_server[25635]: [webserver]<br>
>> a5b403b9-83a9-45b9-a638-0f2b4ce1f4d8  POST params:<br>
>> Jun 14 13:19:59 dns1 pdns_server[25635]: [webserver]<br>
>> a5b403b9-83a9-45b9-a638-0f2b4ce1f4d8   {"name":"<a href="http://example.org" rel="noreferrer" target="_blank">example.org</a>.",<br>
>> "kind":<br>
>> "Native", "masters": [], "nameservers": ["<a href="http://ns1.example.org" rel="noreferrer" target="_blank">ns1.example.org</a>.",<br>
>> "<a href="http://ns2.example.org" rel="noreferrer" target="_blank">ns2.example.org</a>."]}:<br>
>> Jun 14 13:19:59 dns1 pdns_server[25635]: [webserver]<br>
>> a5b403b9-83a9-45b9-a638-0f2b4ce1f4d8  Headers:<br>
>> Jun 14 13:19:59 dns1 pdns_server[25635]: [webserver]<br>
>> a5b403b9-83a9-45b9-a638-0f2b4ce1f4d8   accept: */*<br>
>> Jun 14 13:19:59 dns1 pdns_server[25635]: [webserver]<br>
>> a5b403b9-83a9-45b9-a638-0f2b4ce1f4d8   content-length: 113<br>
>> Jun 14 13:19:59 dns1 pdns_server[25635]: [webserver]<br>
>> a5b403b9-83a9-45b9-a638-0f2b4ce1f4d8   content-type:<br>
>> application/x-www-form-urlencoded<br>
>> Jun 14 13:19:59 dns1 pdns_server[25635]: [webserver]<br>
>> a5b403b9-83a9-45b9-a638-0f2b4ce1f4d8   host: <a href="http://10.58.150.164:8081" rel="noreferrer" target="_blank">10.58.150.164:8081</a><br>
>> Jun 14 13:19:59 dns1 pdns_server[25635]: [webserver]<br>
>> a5b403b9-83a9-45b9-a638-0f2b4ce1f4d8   user-agent: curl/7.68.0<br>
>> Jun 14 13:19:59 dns1 pdns_server[25635]: [webserver]<br>
>> a5b403b9-83a9-45b9-a638-0f2b4ce1f4d8   x-api-key: my-key<br>
>> Jun 14 13:19:59 dns1 pdns_server[25635]: [webserver]<br>
>> a5b403b9-83a9-45b9-a638-0f2b4ce1f4d8  Full body:<br>
>> Jun 14 13:19:59 dns1 pdns_server[25635]: [webserver]<br>
>> a5b403b9-83a9-45b9-a638-0f2b4ce1f4d8   {"name":"<a href="http://example.org" rel="noreferrer" target="_blank">example.org</a>.",<br>
>> "kind":<br>
>> "Native", "masters": [], "nameservers": ["<a href="http://ns1.example.org" rel="noreferrer" target="_blank">ns1.example.org</a>.",<br>
>> "<a href="http://ns2.example.org" rel="noreferrer" target="_blank">ns2.example.org</a>."]}<br>
>> Jun 14 13:19:59 dns1 pdns_server[25635]: [webserver]<br>
>> a5b403b9-83a9-45b9-a638-0f2b4ce1f4d8 Handling request<br>
>> "/api/v1/servers/localhost/zones"<br>
>> Jun 14 13:19:59 dns1 pdns_server[25635]: [webserver]<br>
>> a5b403b9-83a9-45b9-a638-0f2b4ce1f4d8 Result for<br>
>> "/api/v1/servers/localhost/zones": 422, body length: 50<br>
>> Jun 14 13:19:59 dns1 pdns_server[25635]: [webserver]<br>
>> a5b403b9-83a9-45b9-a638-0f2b4ce1f4d8 Response details:<br>
>> Jun 14 13:19:59 dns1 pdns_server[25635]: [webserver]<br>
>> a5b403b9-83a9-45b9-a638-0f2b4ce1f4d8  Headers:<br>
>> Jun 14 13:19:59 dns1 pdns_server[25635]: [webserver]<br>
>> a5b403b9-83a9-45b9-a638-0f2b4ce1f4d8   access-control-allow-origin:<br>
>> *<br>
>> Jun 14 13:19:59 dns1 pdns_server[25635]: [webserver]<br>
>> a5b403b9-83a9-45b9-a638-0f2b4ce1f4d8   Connection: close<br>
>> Jun 14 13:19:59 dns1 pdns_server[25635]: [webserver]<br>
>> a5b403b9-83a9-45b9-a638-0f2b4ce1f4d8   Content-Length: 50<br>
>> Jun 14 13:19:59 dns1 pdns_server[25635]: [webserver]<br>
>> a5b403b9-83a9-45b9-a638-0f2b4ce1f4d8   Content-Security-Policy:<br>
>> default-src 'self'; style-src 'self' 'unsafe-inline'<br>
>> Jun 14 13:19:59 dns1 pdns_server[25635]: [webserver]<br>
>> a5b403b9-83a9-45b9-a638-0f2b4ce1f4d8   Content-Type:<br>
>> application/json<br>
>> Jun 14 13:19:59 dns1 pdns_server[25635]: [webserver]<br>
>> a5b403b9-83a9-45b9-a638-0f2b4ce1f4d8   Server: PowerDNS/4.2.1<br>
>> Jun 14 13:19:59 dns1 pdns_server[25635]: [webserver]<br>
>> a5b403b9-83a9-45b9-a638-0f2b4ce1f4d8   X-Content-Type-Options:<br>
>> nosniff<br>
>> Jun 14 13:19:59 dns1 pdns_server[25635]: [webserver]<br>
>> a5b403b9-83a9-45b9-a638-0f2b4ce1f4d8   X-Frame-Options: deny<br>
>> Jun 14 13:19:59 dns1 pdns_server[25635]: [webserver]<br>
>> a5b403b9-83a9-45b9-a638-0f2b4ce1f4d8<br>
>> X-Permitted-Cross-Domain-Policies: none<br>
>> Jun 14 13:19:59 dns1 pdns_server[25635]: [webserver]<br>
>> a5b403b9-83a9-45b9-a638-0f2b4ce1f4d8   X-XSS-Protection: 1;<br>
>> mode=block<br>
>> Jun 14 13:19:59 dns1 pdns_server[25635]: [webserver]<br>
>> a5b403b9-83a9-45b9-a638-0f2b4ce1f4d8  Full body:<br>
>> Jun 14 13:19:59 dns1 pdns_server[25635]: [webserver]<br>
>> a5b403b9-83a9-45b9-a638-0f2b4ce1f4d8   {"error": "Creating domain<br>
>> '<a href="http://example.org" rel="noreferrer" target="_blank">example.org</a>.' failed"}<br>
>> Jun 14 13:19:59 dns1 pdns_server[25635]: [webserver]<br>
>> a5b403b9-83a9-45b9-a638-0f2b4ce1f4d8 <a href="http://10.58.150.164:39182" rel="noreferrer" target="_blank">10.58.150.164:39182</a> "POST<br>
>> /api/v1/servers/localhost/zones HTTP/1.1" 422 423<br>
>> Tomasz<br>
>> _______________________________________________<br>
>> Pdns-users mailing list<br>
>> <a href="mailto:Pdns-users@mailman.powerdns.com" target="_blank">Pdns-users@mailman.powerdns.com</a><br>
>> <a href="https://mailman.powerdns.com/mailman/listinfo/pdns-users" rel="noreferrer" target="_blank">https://mailman.powerdns.com/mailman/listinfo/pdns-users</a><br>
>> _______________________________________________<br>
>> Pdns-users mailing list<br>
>> <a href="mailto:Pdns-users@mailman.powerdns.com" target="_blank">Pdns-users@mailman.powerdns.com</a><br>
>> <a href="https://mailman.powerdns.com/mailman/listinfo/pdns-users" rel="noreferrer" target="_blank">https://mailman.powerdns.com/mailman/listinfo/pdns-users</a><br>
>  _______________________________________________<br>
> Pdns-users mailing list<br>
> <a href="mailto:Pdns-users@mailman.powerdns.com" target="_blank">Pdns-users@mailman.powerdns.com</a><br>
> <a href="https://mailman.powerdns.com/mailman/listinfo/pdns-users" rel="noreferrer" target="_blank">https://mailman.powerdns.com/mailman/listinfo/pdns-users</a><br>
> Links:<br>
> ------<br>
> [1] <a href="http://example.org" rel="noreferrer" target="_blank">http://example.org</a><br>
> [2] <a href="http://ns1.example.org" rel="noreferrer" target="_blank">http://ns1.example.org</a><br>
> [3] <a href="http://ns2.example.org" rel="noreferrer" target="_blank">http://ns2.example.org</a><br>
_______________________________________________<br>
Pdns-users mailing list<br>
<a href="mailto:Pdns-users@mailman.powerdns.com" target="_blank">Pdns-users@mailman.powerdns.com</a><br>
<a href="https://mailman.powerdns.com/mailman/listinfo/pdns-users" rel="noreferrer" target="_blank">https://mailman.powerdns.com/mailman/listinfo/pdns-users</a><br>
</blockquote></div></div>-- <br><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><br>"Genius might be described as a supreme capacity for getting its possessors<br>into trouble of all kinds."<br>-- Samuel Butler<br></div>