Community

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Popular
    • Users
    • Search

    API create object from template

    Development
    3
    13
    254
    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.
    • Kleinrotti
      Kleinrotti last edited by

      As far as I know it not possible to use the I-doit API to create an object from a template.
      If so, would it be possible to add this to the API Addon?

      LFischer 1 Reply Last reply Reply Quote 0
      • LFischer
        LFischer @Kleinrotti last edited by

        Hey @kleinrotti

        thats correct - you can not directly use the i-doit template system to "mass create" objects by existing templates, but you CAN create objects and use their defined "default template", if this helps you out.

        In order to do so simply pass the option defaultTemplate with any "truthy" value (for example "defaultTemplate": true or "defaultTemplate": 1.

        I hope this helps you out ๐Ÿ™‚

        Kleinrotti 1 Reply Last reply Reply Quote 0
        • Kleinrotti
          Kleinrotti @LFischer last edited by

          @lfischer First of all thanks for your quick response.
          This would help a little bit but unfortunately this isn't working for some reason.
          If a pass the parameter "defaultTemplate" as descripted I get this response:

          The given value is not unique and is already being used in other objects: <ul class="m0 mt10 list-style-none"><li><span>Monitor ยป MON-TEMP-236</span></li></ul><br />{
              "id": 1,
              "jsonrpc": "2.0",
              "result": {
                  "id": 43554,
                  "message": "Object was successfully created",
                  "success": true
              }
          }
          

          The object was created but not with the default template which is selected in the Idoit settings.
          But this only seems to happen with Idoit PRO. On my test machine with Idoit OPEN everything works as expected.

          I used for both installations Idoit 1.17.1 with API Addon 1.12.1.

          LFischer 1 Reply Last reply Reply Quote 0
          • LFischer
            LFischer @Kleinrotti last edited by

            Hey @kleinrotti

            the error message comes from the internal validation, but sadly it does not mention which category or attribute are responsible ๐Ÿ˜• This might prevent one (or more) categories from being created.
            I'll note this down as a bug - the error message should be part of the API response.

            Could you check your validation and if the object does (aside from the affected category) match your default profile?

            Kleinrotti 1 Reply Last reply Reply Quote 0
            • Kleinrotti
              Kleinrotti @LFischer last edited by

              @lfischer The only validation we have is, that the object title needs to be unique. I have tried several object types like Printer, Monitor, Client but I get this error with all them. I tried different templates which I set as default but no chance. Every time the object is created, but none of the categories, no matter which template is set as default, are applied.

              Here is a screenshot from our validation settings.
              e904695c-f4e5-4e3e-84de-76c401d105b8-image.png

              LFischer 1 Reply Last reply Reply Quote 0
              • LFischer
                LFischer @Kleinrotti last edited by

                Hey @kleinrotti

                that's interesting - but I believe we should be able to reproduce this issue very easily. Are you using any placeholders in your object title (either the default template and the object you try to create)?

                I will adjust the bug I previously created... I'm afraid I have no "work around" up my sleeve, so you might need to wait for a new API version.

                I'll also create a feature request regarding "create object from template" ๐Ÿ™‚

                Kleinrotti 1 Reply Last reply Reply Quote 0
                • Kleinrotti
                  Kleinrotti @LFischer last edited by

                  @lfischer No I don't use placeholders in titles of the objects/templates.
                  For testing purposes I disabled the validation/unique setting for the title and it's working this way - no error. But I need this settings for production, so I have to enable it again.
                  This bug definitely has something to do with the validation setting.
                  I would really appreciate if that bug could be fixed and if that feature request would be implemented.

                  1 Reply Last reply Reply Quote 0
                  • Kleinrotti
                    Kleinrotti last edited by

                    @LFischer Are there already any news when a bugfix will be released?

                    LFischer 1 Reply Last reply Reply Quote 0
                    • LFischer
                      LFischer @Kleinrotti last edited by

                      Hey @kleinrotti

                      sadly I have no updates yet, currently we are working on the i-doit 1.17.2 version which is going to be released shortly.
                      I believe after that we will check the API add-on ๐Ÿ™‚

                      Best regards

                      1 Reply Last reply Reply Quote 0
                      • Kleinrotti
                        Kleinrotti last edited by

                        Hey @LFischer
                        are there any new information?

                        LFischer 1 Reply Last reply Reply Quote 0
                        • LFischer
                          LFischer @Kleinrotti last edited by

                          Hi @kleinrotti ,

                          I'm afraid I have no new information for you ๐Ÿ˜ž Right now the team is working on the upcoming i-doit 1.18 version. There will also be a API release around that time, but it will not contain this feature.

                          Best regards

                          Kleinrotti 1 Reply Last reply Reply Quote 0
                          • Kleinrotti
                            Kleinrotti @LFischer last edited by

                            @lfischer
                            And what about the bugfix for the default template? Even that would help me ๐Ÿ™‚

                            LFischer 1 Reply Last reply Reply Quote 0
                            • LFischer
                              LFischer @Kleinrotti last edited by

                              Hey @kleinrotti

                              again - sadly no updates regarding this topic ๐Ÿ˜ž

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