[Pdns-users] 405 Method Not Allowed error returned from zone update HTTP PATCH method against JSON REST API

Christian Hofstaedtler christian.hofstaedtler at deduktiva.com
Tue Feb 3 11:48:34 UTC 2015


> On 03 Feb 2015, at 00:26, Jordan Rieger <jordan at webnames.ca> wrote:
> I'm writing code to interface with the HTTP JSON REST API of a PowerDNS 3.4.1 authoritative server with a MySQL backend.


> I tried increasing the server log level to 9 (the maximum), and I see my request in the log, but it only shows the request size and the fact that it caused a 405 error, which I already know.

Indeed, the logging could be more useful.

> It doesn't seem to matter what content the PATCH request actually contains, what zone I use, or even if the zone exists at all. It seems to just be the PATCH method itself causing the problem. This makes me think that it is a simple configuration problem on the server. Maybe the internal HTTP server component is rejecting PATCH requests by default?
> Anyways, here is the request. This is attempting to delete all TXT records on example.com:
> /servers/localhost/zones/example.com PATCH {"rrsets":[{"name":"example.com","type":"TXT","changetype":"DELETE","records":[],"comments":[]}]}

So, a full `curl` command line or a XHR dump would be useful.
For what I can see, if you’re able to POST/DELETE zones, PATCH should also work.

Can you try the steps with curl outlined in https://doc.powerdns.com/md/httpapi/README/#try-it , as those exactly create a zone and then PATCH it.

Based on the instructions from the intro sections, I tried your request with curl, and that does seem to work:

curl -X PATCH --data '{"rrsets":[{"name":"example.org","type":"TXT","changetype":"DELETE","records":[],"comments":[]}]}' -H 'X-API-Key: changeme' -v

< HTTP/1.1 200 OK

{"id":"example.org.","url":"/servers/localhost/zones/example.org.","name":"example.org","type":"Zone","kind":"Master","dnssec":false,"soa_edit_api":"","soa_edit":"","masters":[],"serial":2002022401,"notified_serial":0,"last_check":0,"records":[{"name":"bill.example.org","type":"A","ttl":86400,"disabled":false,"content":""},{"name":"example.org","type":"MX","ttl":86400,"disabled":false,"content":"10 mail.another.com"},{"name":"example.org","type":"NS","ttl":86400,"disabled":false,"content":"ns1.example.org"},{"name":"example.org","type":"NS","ttl":86400,"disabled":false,"content":"ns2.smokeyjoe.com"},{"name":"example.org","type":"SOA","ttl":86400,"disabled":false,"content":"ns1.example.org. hostmaster.example.org. 2002022401 10800 15 604800 10800"},{"name":"fred.example.org","type":"A","ttl":86400,"disabled":false,"content":""},{"name":"ftp.example.org","type":"CNAME","ttl":86400,"disabled":false,"content":"www.example.org"},{"name":"ns1.example.org","type":"A","ttl":86400,"disabled":false,"content":""},{"name":"test.example.org","type":"A","ttl":86400,"disabled":false,"content":""},{"name":"www.example.org","type":"A","ttl":86400,"disabled":false,"content":""}],"comments":[]}

Christian Hofstaedtler / Deduktiva GmbH (FN 418592 b, HG Wien)
www.deduktiva.com / +43 1 353 1707

More information about the Pdns-users mailing list