XCP-ng
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Register
    • Login

    Netbox plugin: Error code 400 - Error: Bad Request

    Scheduled Pinned Locked Moved Advanced features
    32 Posts 4 Posters 8.0k Views 3 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • pdoniasP Offline
      pdonias Vates 🪐 XO Team @mavoff
      last edited by

      Nice catch @Danp 🙂
      @maverick, maybe you forgot to restart xo-server?

      M 1 Reply Last reply Reply Quote 0
      • M Offline
        mavoff @pdonias
        last edited by mavoff

        @pdonias thank you for your reply.

        I restarted the whole server before actually testing.

        the screenshot above was immediately after the build but before the reboot. Was focused on the commit.
        Then rebooted, tested, error.

        Screenshot 2023-10-24 at 14.58.03.png

        pdoniasP 1 Reply Last reply Reply Quote 0
        • olivierlambertO Offline
          olivierlambert Vates 🪐 Co-Founder CEO
          last edited by

          Okay so now at least you are on a right build 🙂

          1 Reply Last reply Reply Quote 1
          • pdoniasP Offline
            pdonias Vates 🪐 XO Team @mavoff
            last edited by

            @maverick What version of the Netbox plugin do you see in the UI? (/#/settings/plugins?s=netbox)

            M 1 Reply Last reply Reply Quote 1
            • M Offline
              mavoff @pdonias
              last edited by

              @pdonias said in Netbox plugin: Error code 400 - Error: Bad Request:

              /#/settings/plugins?s=netbox

              Netbox 1.3.0

              pdoniasP 1 Reply Last reply Reply Quote 0
              • pdoniasP Offline
                pdonias Vates 🪐 XO Team @mavoff
                last edited by pdonias

                @maverick Thanks, that seems correct. So you're getting the exact same error as before when you test the plugin? Now that you're up-to-date, you should get more information in the full error log.

                M 1 Reply Last reply Reply Quote 0
                • M Offline
                  mavoff @pdonias
                  last edited by

                  @pdonias

                  Hi there and thank you for your reply.
                  Well, the error messages aren't exactly equal so to say.

                  In the image below you can see the result of testing before the XO update was completed (namely the Oct 24 11:11 test was made after update BEFORE reboot/xo restart and 11:16 was after).
                  So the error message does change slightly.

                  Screenshot 2023-10-25 at 11.19.14.png

                  Oct 24, 11:11

                  plugin.test
                  {
                    "id": "netbox"
                  }
                  {
                    "code": 400,
                    "url": "https://fw-dea12.domain.tld:8143/api/virtualization/cluster-types/",
                    "data": {
                      "method": "POST",
                      "path": "/virtualization/cluster-types/",
                      "body": {
                        "name": "[TMP] Xen Orchestra Netbox plugin test - 5qz91pafh",
                        "slug": "xo-test-5qz91pafh",
                        "description": "This type has been created by Xen Orchestra's Netbox plugin test. If it hasn't been properly deleted, you may delete it manually."
                      }
                    },
                    "message": "Bad Request",
                    "name": "Error",
                    "stack": "Error: Bad Request
                      at onResponse (/opt/xen-orchestra/node_modules/http-request-plus/index.js:255:21)
                      at AsyncResource.runInAsyncScope (node:async_hooks:199:9)
                      at cb (/opt/xen-orchestra/node_modules/bluebird/js/release/util.js:355:42)
                      at tryCatcher (/opt/xen-orchestra/node_modules/bluebird/js/release/util.js:16:23)
                      at Promise._settlePromiseFromHandler (/opt/xen-orchestra/node_modules/bluebird/js/release/promise.js:547:31)
                      at Promise._settlePromise (/opt/xen-orchestra/node_modules/bluebird/js/release/promise.js:604:18)
                      at Promise._settlePromise0 (/opt/xen-orchestra/node_modules/bluebird/js/release/promise.js:649:10)
                      at Promise._settlePromises (/opt/xen-orchestra/node_modules/bluebird/js/release/promise.js:729:18)
                      at _drainQueueStep (/opt/xen-orchestra/node_modules/bluebird/js/release/async.js:93:12)
                      at _drainQueue (/opt/xen-orchestra/node_modules/bluebird/js/release/async.js:86:9)
                      at Async._drainQueues (/opt/xen-orchestra/node_modules/bluebird/js/release/async.js:102:5)
                      at Immediate.Async.drainQueues [as _onImmediate] (/opt/xen-orchestra/node_modules/bluebird/js/release/async.js:15:14)
                      at processImmediate (node:internal/timers:464:21)
                      at process.callbackTrampoline (node:internal/async_hooks:130:17)"
                  }
                  

                  And Oct 24, 11:16:

                  plugin.test
                  {
                    "id": "netbox"
                  }
                  {
                    "originalUrl": "https://fw-dea12.domain.tld:8143/api/extras/custom-fields/",
                    "url": "https://fw-dea12.domain.tld:8143/api/extras/custom-fields/",
                    "data": {
                      "method": "GET",
                      "path": "/extras/custom-fields/"
                    },
                    "message": "400 Bad Request",
                    "name": "Error",
                    "stack": "Error: 400 Bad Request
                      at Object.assertSuccess (/opt/xen-orchestra/node_modules/http-request-plus/index.js:162:19)
                      at httpRequestPlus (/opt/xen-orchestra/node_modules/http-request-plus/index.js:217:22)
                      at httpRequest (/opt/xen-orchestra/packages/xo-server-netbox/src/index.js:146:26)
                      at Netbox.#request (/opt/xen-orchestra/packages/xo-server-netbox/src/index.js:183:18)
                      at Netbox.#checkCustomFields (/opt/xen-orchestra/packages/xo-server-netbox/src/index.js:203:26)
                      at Netbox.test (/opt/xen-orchestra/packages/xo-server-netbox/src/index.js:106:5)
                      at default.testPlugin (file:///opt/xen-orchestra/packages/xo-server/src/xo-mixins/plugins.mjs:285:5)
                      at Xo.test (file:///opt/xen-orchestra/packages/xo-server/src/api/plugin.mjs:109:3)
                      at Api.#callApiMethod (file:///opt/xen-orchestra/packages/xo-server/src/xo-mixins/api.mjs:417:20)"
                  }
                  
                  pdoniasP 1 Reply Last reply Reply Quote 0
                  • pdoniasP Offline
                    pdonias Vates 🪐 XO Team @mavoff
                    last edited by

                    @maverick It's weird because the error log should have more fields. Are you able to access this URL from a browser where you're logged in your Netbox? https://fw-dea12.domain.tld:8143/api/extras/custom-fields/

                    M 1 Reply Last reply Reply Quote 0
                    • M Offline
                      mavoff @pdonias
                      last edited by

                      @pdonias hi there sorry for the late reply.

                      If I open said link on the browser I get:Screenshot 2023-10-26 at 16.54.47.png

                      pdoniasP 1 Reply Last reply Reply Quote 0
                      • pdoniasP Offline
                        pdonias Vates 🪐 XO Team @mavoff
                        last edited by

                        @maverick Please make sure that you're logged in by going to https://fw-dea12.domain.tld:8143/ first.

                        M 1 Reply Last reply Reply Quote 0
                        • M Offline
                          mavoff @pdonias
                          last edited by

                          @pdonias

                          Just to say that yes the link is accessible.

                          HTTP 200 OK
                          Allow: GET, POST, PUT, PATCH, DELETE, HEAD, OPTIONS
                          Content-Type: application/json
                          Vary: Accept
                          
                          {
                              "count": 1,
                              "next": null,
                              "previous": null,
                              "results": [
                                  {
                                      "id": 1,
                                      "url": "https://fw-dea12.domain.tld/api/extras/custom-fields/1/",
                                      "display": "UUID",
                                      "content_types": [
                                          "virtualization.cluster",
                                          "virtualization.virtualmachine",
                                          "virtualization.vminterface"
                                      ],
                                      "type": {
                                          "value": "longtext",
                                          "label": "Text (long)"
                                      },
                                      "object_type": null,
                                      "data_type": "string",
                                      "name": "uuid",
                                      "label": "UUID",
                                      "group_name": "",
                                      "description": "Object UUID",
                                      "required": false,
                                      "search_weight": 1000,
                                      "filter_logic": {
                                          "value": "exact",
                                          "label": "Exact"
                                      },
                                      "ui_visibility": {
                                          "value": "read-write",
                                          "label": "Read/Write"
                                      },
                                      "default": null,
                                      "weight": 100,
                                      "validation_minimum": null,
                                      "validation_maximum": null,
                                      "validation_regex": "",
                                      "choices": [],
                                      "created": "2023-10-17T12:20:53.892582Z",
                                      "last_updated": "2023-10-17T12:21:47.628430Z"
                                  }
                              ]
                          }
                          

                          Logged in

                          pdoniasP 1 Reply Last reply Reply Quote 0
                          • pdoniasP Offline
                            pdonias Vates 🪐 XO Team @mavoff
                            last edited by

                            @maverick This is for the URL https://fw-dea12.domain.tld/api/extras/custom-fields/1/, right? What about https://fw-dea12.domain.tld/api/extras/custom-fields/?

                            If that works too, could you run this from the machine that hosts your XO?
                            Replace <TOKEN> with the token that you put in the Netbox plugin configuration:

                            curl -skv -H "Content-Type: application/json" -H "Authorization: Token <TOKEN>" "https://fw-dea12.domain.tld/api/extras/custom-fields/"
                            
                            M 1 Reply Last reply Reply Quote 1
                            • M Offline
                              mavoff @pdonias
                              last edited by

                              @pdonias ok I get a correct answer from inside but from outside I'm getting this bad request. The curl gets to the ssl certificate on the net box host, but throws the 400 bad request, when doing from outside the firewall.

                              When testing locally, it works.

                              Let me look this over! Thanks!

                              1 Reply Last reply Reply Quote 0
                              • First post
                                Last post