[GH-ISSUE #162] nsedit get api error after pdns upgrade 4.1 #105

Closed
opened 2026-02-28 01:21:00 +03:00 by kerem · 9 comments
Owner

Originally created by @p2107 on GitHub (Dec 6, 2017).
Original GitHub issue: https://github.com/tuxis-ie/nsedit/issues/162

nsedit does not work after upgrade from pdns 4.0 to 4.1 I get API error 404 not found when edit or create zone/record. Is there some fix?

Originally created by @p2107 on GitHub (Dec 6, 2017). Original GitHub issue: https://github.com/tuxis-ie/nsedit/issues/162 nsedit does not work after upgrade from pdns 4.0 to 4.1 I get API error 404 not found when edit or create zone/record. Is there some fix?
kerem closed this issue 2026-02-28 01:21:00 +03:00
Author
Owner

@margau commented on GitHub (Mar 2, 2018):

Hallo,
same problem here.

@tuxis-ie
Is there any kind of debug output so i may can look into the issue?

Best regards
margau

<!-- gh-comment-id:369921225 --> @margau commented on GitHub (Mar 2, 2018): Hallo, same problem here. @tuxis-ie Is there any kind of debug output so i may can look into the issue? Best regards margau
Author
Owner

@lvo12 commented on GitHub (Mar 27, 2018):

Same problem here.

<!-- gh-comment-id:376466727 --> @lvo12 commented on GitHub (Mar 27, 2018): Same problem here.
Author
Owner

@skfigved commented on GitHub (Mar 27, 2018):

Same here as well

<!-- gh-comment-id:376502289 --> @skfigved commented on GitHub (Mar 27, 2018): Same here as well
Author
Owner

@tuxis-ie commented on GitHub (Mar 28, 2018):

https://github.com/tuxis-ie/nsedit/blob/master/includes/class/ApiHandler.php#L71 is where the magic happens. So you can debug some stuff there.

Calling zones.php directly (use inspector in your browser to see which calls are made) might give some useful output then.

<!-- gh-comment-id:376784730 --> @tuxis-ie commented on GitHub (Mar 28, 2018): https://github.com/tuxis-ie/nsedit/blob/master/includes/class/ApiHandler.php#L71 is where the magic happens. So you can debug some stuff there. Calling zones.php directly (use inspector in your browser to see which calls are made) might give some useful output then.
Author
Owner

@paulgiordanozethcon commented on GitHub (Mar 28, 2018):

Try this:

--- ApiHandler.php      2018-03-28 07:36:21.833684298 -0500
+++ ApiHandler-fixed.php        2018-03-28 07:37:07.093835996 -0500
@@ -29,15 +29,19 @@
     private function apiurl() {
         $tmp = new ApiHandler();

-        $tmp->url = '/api';
+        $tmp->url = '/api/v1/servers/localhost';
         $tmp->go();
-
-        if ($tmp->json[0]['version'] <= 1) {
-            $this->apiurl = $tmp->json[0]['url'];
+               $v = intval(substr($tmp->json["version"],0,1));
+        if ($v == 4) {
+            $this->apiurl = $tmp->json["url"];
         } else {
             throw new Exception("Unsupported API version");
         }
-
     }

     private function curlopts() {

--- PdnsApi.php 2018-03-28 07:36:21.833684298 -0500
+++ PdnsApi-fixed.php   2018-03-28 07:40:13.762461478 -0500
@@ -11,7 +11,7 @@
         $api = clone $this->http;
         $api->method = 'GET';
         if ($q) {
-            $api->url = "/servers/localhost/search-data?q=*".$q."*&max=25";
+            $api->url = "/search-data?q=*".$q."*&max=25";
             $api->call();
             $ret = Array();
             $seen = Array();
@@ -28,7 +28,7 @@

             return $ret;
         }
-        $api->url = "/servers/localhost/zones";
+        $api->url = "/zones";
         $api->call();

         return $api->json;
@@ -37,7 +37,7 @@
     public function loadzone($zoneid) {
         $api = clone $this->http;
         $api->method = 'GET';
-        $api->url = "/servers/localhost/zones/$zoneid";
+        $api->url = "/zones/$zoneid";
         $api->call();

         return $api->json;
@@ -46,7 +46,7 @@
     public function exportzone($zoneid) {
         $api = clone $this->http;
         $api->method = 'GET';
-        $api->url = "/servers/localhost/zones/$zoneid/export";
+        $api->url = "/zones/$zoneid/export";
         $api->call();

         return $api->json;
@@ -64,7 +64,7 @@

         if (!isset($zone['serial']) or gettype($zone['serial']) != 'integer') {
             $api->method = 'POST';
-            $api->url = '/servers/localhost/zones';
+            $api->url = '/localhost/zones';
             $api->content = json_encode($zonedata);
             $api->call();

@@ -88,7 +88,7 @@
     public function deletezone($zoneid) {
         $api = clone $this->http;
         $api->method = 'DELETE';
-        $api->url = "/servers/localhost/zones/$zoneid";
+        $api->url = "/zones/$zoneid";
         $api->call();

         return $api->json;
@@ -98,7 +98,7 @@
         $ret = array();
         $api = clone $this->http;
         $api->method = 'GET';
-        $api->url = "/servers/localhost/zones/$zoneid/cryptokeys";
+        $api->url = "/zones/$zoneid/cryptokeys";

         $api->call();
<!-- gh-comment-id:376873032 --> @paulgiordanozethcon commented on GitHub (Mar 28, 2018): Try this: ``` --- ApiHandler.php 2018-03-28 07:36:21.833684298 -0500 +++ ApiHandler-fixed.php 2018-03-28 07:37:07.093835996 -0500 @@ -29,15 +29,19 @@ private function apiurl() { $tmp = new ApiHandler(); - $tmp->url = '/api'; + $tmp->url = '/api/v1/servers/localhost'; $tmp->go(); - - if ($tmp->json[0]['version'] <= 1) { - $this->apiurl = $tmp->json[0]['url']; + $v = intval(substr($tmp->json["version"],0,1)); + if ($v == 4) { + $this->apiurl = $tmp->json["url"]; } else { throw new Exception("Unsupported API version"); } - } private function curlopts() { --- PdnsApi.php 2018-03-28 07:36:21.833684298 -0500 +++ PdnsApi-fixed.php 2018-03-28 07:40:13.762461478 -0500 @@ -11,7 +11,7 @@ $api = clone $this->http; $api->method = 'GET'; if ($q) { - $api->url = "/servers/localhost/search-data?q=*".$q."*&max=25"; + $api->url = "/search-data?q=*".$q."*&max=25"; $api->call(); $ret = Array(); $seen = Array(); @@ -28,7 +28,7 @@ return $ret; } - $api->url = "/servers/localhost/zones"; + $api->url = "/zones"; $api->call(); return $api->json; @@ -37,7 +37,7 @@ public function loadzone($zoneid) { $api = clone $this->http; $api->method = 'GET'; - $api->url = "/servers/localhost/zones/$zoneid"; + $api->url = "/zones/$zoneid"; $api->call(); return $api->json; @@ -46,7 +46,7 @@ public function exportzone($zoneid) { $api = clone $this->http; $api->method = 'GET'; - $api->url = "/servers/localhost/zones/$zoneid/export"; + $api->url = "/zones/$zoneid/export"; $api->call(); return $api->json; @@ -64,7 +64,7 @@ if (!isset($zone['serial']) or gettype($zone['serial']) != 'integer') { $api->method = 'POST'; - $api->url = '/servers/localhost/zones'; + $api->url = '/localhost/zones'; $api->content = json_encode($zonedata); $api->call(); @@ -88,7 +88,7 @@ public function deletezone($zoneid) { $api = clone $this->http; $api->method = 'DELETE'; - $api->url = "/servers/localhost/zones/$zoneid"; + $api->url = "/zones/$zoneid"; $api->call(); return $api->json; @@ -98,7 +98,7 @@ $ret = array(); $api = clone $this->http; $api->method = 'GET'; - $api->url = "/servers/localhost/zones/$zoneid/cryptokeys"; + $api->url = "/zones/$zoneid/cryptokeys"; $api->call(); ```
Author
Owner

@skfigved commented on GitHub (Apr 12, 2018):

Did anyone get it working?

<!-- gh-comment-id:380704001 --> @skfigved commented on GitHub (Apr 12, 2018): Did anyone get it working?
Author
Owner

@tuxis-ie commented on GitHub (Apr 12, 2018):

On Thu, 2018-04-12 at 07:20 +0000, skf82 wrote:

Did anyone get it working?

Didn't Pauls suggestion help you?

--
Kerio Operator in de Cloud? https://www.kerioindecloud.nl/
Mark Schouten | Tuxis Internet Engineering
KvK: 61527076 | http://www.tuxis.nl/
T: 0318 200208 | info@tuxis.nl

<!-- gh-comment-id:380716622 --> @tuxis-ie commented on GitHub (Apr 12, 2018): On Thu, 2018-04-12 at 07:20 +0000, skf82 wrote: > Did anyone get it working? Didn't Pauls suggestion help you? -- Kerio Operator in de Cloud? https://www.kerioindecloud.nl/ Mark Schouten | Tuxis Internet Engineering KvK: 61527076 | http://www.tuxis.nl/ T: 0318 200208 | info@tuxis.nl
Author
Owner

@lvo12 commented on GitHub (Apr 12, 2018):

Could someone post how to patch these files? I tried this: patch foo.c < patch.diff

But that fails on line 23 for the ApiHandler.php file.
It runs fine on the PdnsApi.php file.

<!-- gh-comment-id:380796621 --> @lvo12 commented on GitHub (Apr 12, 2018): Could someone post how to patch these files? I tried this: patch foo.c < patch.diff But that fails on line 23 for the ApiHandler.php file. It runs fine on the PdnsApi.php file.
Author
Owner

@skfigved commented on GitHub (Apr 18, 2018):

I fixed this issue by redownloading from master and reusing the config.inc.php

<!-- gh-comment-id:382266392 --> @skfigved commented on GitHub (Apr 18, 2018): I fixed this issue by redownloading from master and reusing the config.inc.php
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/nsedit#105
No description provided.