Running the HTTP request in an outside tool, rather than my own code, was the 
key to debugging it. It looks like the problem was caused by an issue in an 
HTTP helper method on my end. I thought I was setting the HTTP verb to "PATCH" 
but my helper method was actually overwriting it with "POST", and that was 
causing the PowerDNS server, naturally, to reject it.

Thanks for your help, Christian.

-----Original Message-----
From: Christian Hofstaedtler [mailto:[email protected]] 
Sent: Tuesday, February 03, 2015 3:49 AM
To: Jordan Rieger
Cc: [email protected]
Subject: Re: [Pdns-users] 405 Method Not Allowed error returned from zone 
update HTTP PATCH method against JSON REST API

Hi!


> 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:
> 
> 10.9.9.64:8081 /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' 
http://127.0.0.1:8081/servers/localhost/zones/example.org -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":"192.168.0.3"},{"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":"192.168.0.4"},{"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":"192.168.0.1"},{"name":"test.example.org","type":"A","ttl":86400,"disabled":false,"content":"1.1.1.1"},{"name":"www.example.org","type":"A","ttl":86400,"disabled":false,"content":"192.168.0.2"}],"comments":[]}


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







_______________________________________________
Pdns-users mailing list
[email protected]
http://mailman.powerdns.com/mailman/listinfo/pdns-users

Reply via email to