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

    Changing Language in json api

    Scheduled Pinned Locked Moved Development
    5 Posts 3 Posters 1.6k Views 1 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.
    • A Offline
      ali
      last edited by

      hi,
      I'm using i-doit api to get objects and list of each object's categories
      The problem is I want to show details of each category in other language(like German)

      {
          "jsonrpc": "2.0",
          "result": [
              {
                  "id": "9",
                  "objID": "933",
                  "title": "Intel(R) Core(TM)2 Quad CPU Q8200 @ 2.33GHz [4 core(s) x86_64]",
                  "manufacturer": null,
                  "type": null,
                  "frequency": {
                      "title": 2.333
                  },
                  "frequency_unit": {
                      "id": "3",
                      "title": "GHz",
                      "const": "C__FREQUENCY_UNIT__GHZ",
                      "title_lang": "GHz"
                  },
                  "cores": "1",
                  "description": ""
              }
          ],
          "id": null
      }
      

      the code above is the response of calling cpu category for an object,I want to have an output like this code:

      {
          "jsonrpc": "2.0",
          "result": [
              {
                  "id": "9",
                  "objID": "933",
                  "عنوان": "Intel(R) Core(TM)2 Quad CPU Q8200 @ 2.33GHz [4 core(s) x86_64]",
                  "سازنده": null,
                  "نوع": null,
                  "پردازنده": {
                      "عنوان": 2.333
                  },
                  "واحد فرکانس": {
                      "id": "3",
                      "عنوان": "GHz",
                      "const": "C__FREQUENCY_UNIT__GHZ",
                      "title_lang": "GHz"
                  },
                  "تعداد هسته": "1",
                  "توضیحات": ""
              }
          ],
          "id": null
      }
      

      is the a file to change title of details of each category?
      if there is none how this task can be done?

      1 Reply Last reply Reply Quote 0
      • V Offline
        vqh
        last edited by

        Hello ali,

        thank you for using our json api. Unfortunately that is not possible, because the keys which you want to change are just attribute keys which serves only as an identifier of the attribute from the category.
        If you want the get detailed info about the category we have a separate api call which is: cmdb.category_info.read
        For Example:

        
        {
            "params": 
             {
                  "apikey": "12345", 
                  "language": "en", 
                  "category": "C__CATG__CPU"
             }, 
             "method": "cmdb.category_info.read", 
             "version": "2.0"
        }
        
        

        Response:

        
        {
            "jsonrpc": "2.0",
            "result": {
                "title": {
                    "title": "Title",
                    "info": {
                        "primary_field": false,
                        "type": "text",
                        "backward": false,
                        "title": "LC__CMDB__CATG__CPU_TITLE",
                        "description": "Title"
                    },
                    "data": {
                        "type": "text",
                        "readonly": false,
                        "index": false,
                        "field": "isys_catg_cpu_list__title"
                    },
                    "ui": {
                        "type": "text",
                        "default": null,
                        "params": {
                            "p_nMaxLen": 255
                        },
                        "id": "C__CATG__CPU_TITLE"
                    },
                    "format": null,
                    "check": {
                        "mandatory": false
                    }
                },
                "manufacturer": {
                    "title": "Manufacturer",
                    "info": {
                        "primary_field": false,
                        "type": "dialog_plus",
                        "backward": false,
                        "title": "LC__CATG__STORAGE_CONTROLLER_MANUFACTURER",
                        "description": "Manufacturer"
                    },
                    "data": {
                        "type": "int",
                        "readonly": false,
                        "index": false,
                        "field": "isys_catg_cpu_list__isys_catg_cpu_manufacturer__id",
                        "source_table": "isys_catg_cpu_manufacturer",
                        "references": [
                            "isys_catg_cpu_manufacturer",
                            "isys_catg_cpu_manufacturer__id"
                        ],
                        "select": [],
                        "join": [
                            [],
                            []
                        ]
                    },
                    "ui": {
                        "type": "popup",
                        "params": {
                            "p_strPopupType": "dialog_plus",
                            "p_strTable": "isys_catg_cpu_manufacturer"
                        },
                        "default": "-1",
                        "id": "C__CATG__CPU_MANUFACTURER"
                    },
                    "format": {
                        "callback": [
                            "isys_export_helper",
                            "dialog_plus"
                        ]
                    },
                    "check": {
                        "mandatory": null
                    }
                },
                "type": {
                    "title": "Type",
                    "info": {
                        "primary_field": false,
                        "type": "dialog_plus",
                        "backward": false,
                        "title": "LC__CMDB__CATG__CPU_TYPE",
                        "description": "Type"
                    },
                    "data": {
                        "type": "int",
                        "readonly": false,
                        "index": false,
                        "field": "isys_catg_cpu_list__isys_catg_cpu_type__id",
                        "source_table": "isys_catg_cpu_type",
                        "references": [
                            "isys_catg_cpu_type",
                            "isys_catg_cpu_type__id"
                        ],
                        "select": [],
                        "join": [
                            [],
                            []
                        ]
                    },
                    "ui": {
                        "type": "popup",
                        "params": {
                            "p_strPopupType": "dialog_plus",
                            "p_strTable": "isys_catg_cpu_type"
                        },
                        "default": "-1",
                        "id": "C__CATG__CPU_TYPE"
                    },
                    "format": {
                        "callback": [
                            "isys_export_helper",
                            "dialog_plus"
                        ]
                    },
                    "check": {
                        "mandatory": null
                    }
                },
                "frequency": {
                    "title": "CPU frequency",
                    "info": {
                        "primary_field": false,
                        "type": "float",
                        "backward": false,
                        "title": "LC__CMDB__CATG__FREQUENCY",
                        "description": "CPU frequency"
                    },
                    "data": {
                        "type": "float",
                        "readonly": false,
                        "index": false,
                        "field": "isys_catg_cpu_list__frequency",
                        "source_table": "isys_catg_cpu_frequency",
                        "select": [],
                        "join": [
                            [],
                            []
                        ]
                    },
                    "ui": {
                        "type": "text",
                        "default": null,
                        "params": {
                            "p_strPlaceholder": "0.00",
                            "p_strTable": "isys_catg_cpu_frequency",
                            "p_strClass": "input-medium"
                        },
                        "id": "C__CATG__CPU_FREQUENCY"
                    },
                    "format": {
                        "callback": [
                            "isys_export_helper",
                            "convert",
                            [
                                "frequency"
                            ]
                        ],
                        "unit": "frequency_unit"
                    },
                    "check": {
                        "mandatory": false
                    }
                },
                "frequency_unit": {
                    "title": "CPU frequency unit",
                    "info": {
                        "primary_field": false,
                        "type": "dialog",
                        "backward": false,
                        "title": "LC__CMDB__CATG__CPU_FREQUENCY_UNIT",
                        "description": "frequency unit"
                    },
                    "data": {
                        "type": "int",
                        "readonly": false,
                        "index": false,
                        "field": "isys_catg_cpu_list__isys_frequency_unit__id",
                        "source_table": "isys_frequency_unit",
                        "references": [
                            "isys_frequency_unit",
                            "isys_frequency_unit__id"
                        ],
                        "select": [],
                        "join": [
                            [],
                            []
                        ]
                    },
                    "ui": {
                        "type": "dialog",
                        "params": {
                            "p_strTable": "isys_frequency_unit",
                            "p_bDbFieldNN": 0,
                            "p_strClass": "input-mini"
                        },
                        "default": "-1",
                        "id": "C__CATG__CPU_FREQUENCY_UNIT"
                    },
                    "format": {
                        "callback": [
                            "isys_export_helper",
                            "dialog"
                        ]
                    },
                    "check": {
                        "mandatory": null
                    }
                },
                "cores": {
                    "title": "CPU cores",
                    "info": {
                        "primary_field": false,
                        "type": "int",
                        "backward": false,
                        "title": "LC__CMDB__CATG__CPU_CORES",
                        "description": "CPU cores"
                    },
                    "data": {
                        "type": "int",
                        "readonly": false,
                        "index": false,
                        "field": "isys_catg_cpu_list__cores"
                    },
                    "ui": {
                        "type": "text",
                        "params": {
                            "p_strPlaceholder": "0",
                            "default": "0",
                            "p_strClass": "input-mini"
                        },
                        "default": null,
                        "id": "C__CATG__CPU_CORES"
                    },
                    "format": null,
                    "check": {
                        "mandatory": false
                    }
                },
                "description": {
                    "title": "Description",
                    "info": {
                        "primary_field": false,
                        "type": "commentary",
                        "backward": false,
                        "title": "LC__CMDB__LOGBOOK__DESCRIPTION",
                        "description": "Description"
                    },
                    "data": {
                        "type": "text_area",
                        "readonly": false,
                        "index": false,
                        "field": "isys_catg_cpu_list__description"
                    },
                    "ui": {
                        "type": "textarea",
                        "default": null,
                        "id": "C__CMDB__CAT__COMMENTARY_04"
                    },
                    "format": null,
                    "check": {
                        "mandatory": false
                    }
                }
            },
            "id": null
        }
        

        You can find more information about custom languages in https://kb.i-doit.com/display/en/Localization.

        best regards,
        vqh

        1 Reply Last reply Reply Quote 0
        • A Offline
          ali
          last edited by

          Hi vqh,
          Thank You For Your Answer.
          How Can I Get The Following Output From API?

          For Example Get This Result:

          
          {
              "jsonrpc": "2.0",
              "result": {
                  "General": {
                      "Title": "Che2-L11-d26265a05f6938c3",
                      "Category": "",
                      "Purpose": "",
                      "Condition": "Normal",
                      "CMDB status": "in operation ",
                      "Object ID": "1451",
                      "Object type": "کلاینت",
                      "SYSID": "SYSID_1494946391",
                      "Creation date": "2017-05-16 - 16:29:00 (admin)",
                      "SYSID": "SYSID_1494946391",
                      "Date of change": "2017-08-17 - 10:19:33 (admin)",
                      "Tags": "",
                      "Description": "",
                      },
                  "Model": {
                      "سازنده": "HUAWEI",
                      "Model": "Che2-L11",
                      "Product ID": "",
                      "Service Tag": "",
                      "Serial number": "BY2XRJ156W042704",
                      "Firmware": "unknown",
                      "Description": "",
                      }
                  }
          }
          
          
          1 Reply Last reply Reply Quote 0
          • V Offline
            vqh
            last edited by

            Hello ali,

            here is an example how you can get the global category General and Model via API:

            API Call:

            [
              {
                   params:
                   {
                       apikey: 12345,
                       category: 'C__CATG__GLOBAL',
                       objID: 9999
                   },
                   method: 'cmdb.category.read',
                   version: '2.0'
              },
              {
                   params:
                   {
                       apikey: 12345,
                       category: 'C__CATG__MODEL',
                       objID: 9999
                   },
                   method: 'cmdb.category.read',
                   version: '2.0'
              }
            ]
            

            And here is the response you would get:

            [
                {
                    "jsonrpc": "2.0",
                    "result": [
                        {
                            "id": "3307",
                            "objID": "3307",
                            "title": "Test Client 1",
                            "status": {
                                "id": "2",
                                "title": "Normal",
                                "const": "",
                                "title_lang": "LC__CMDB__RECORD_STATUS__NORMAL"
                            },
                            "created": "2017-01-10 13:28:24",
                            "created_by": "admin",
                            "changed": "2017-08-29 15:06:11",
                            "changed_by": "admin",
                            "purpose": null,
                            "category": null,
                            "sysid": "SYSID_1484051304",
                            "cmdb_status": {
                                "id": "6",
                                "title": "in operation",
                                "const": "C__CMDB_STATUS__IN_OPERATION",
                                "title_lang": "LC__CMDB_STATUS__IN_OPERATION"
                            },
                            "type": {
                                "id": "10",
                                "title": "Client",
                                "const": "C__OBJTYPE__CLIENT",
                                "title_lang": "LC__CMDB__OBJTYPE__CLIENT"
                            },
                            "tag": null,
                            "description": ""
                        }
                    ],
                    "error": null,
                    "id": null
                },
                {
                    "jsonrpc": "2.0",
                    "result": [
                        {
                            "id": "166",
                            "objID": "3307",
                            "manufacturer": {
                                "id": "15",
                                "title": "Acer",
                                "const": null,
                                "title_lang": "Acer"
                            },
                            "title": {
                                "id": "157",
                                "title": "AL2223W",
                                "const": null,
                                "title_lang": "AL2223W"
                            },
                            "productid": "ProductID-1010101",
                            "service_tag": "Service-Tag 020202",
                            "serial": "abcdefg",
                            "firmware": "1.0",
                            "description": ""
                        }
                    ],
                    "error": null,
                    "id": null
                }
            ]
            

            I hope that this is helpful to you.

            best regards,
            vqh

            1 Reply Last reply Reply Quote 0
            • C Offline
              Creeno
              last edited by

              This works like a charm. I was wondering the same thing. Thanks.

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