Clarity Service Management

Expand all | Collapse all

Which is the pattern of the JSON/XML on CA SDM?

Jump to Best Answer
  • 1.  Which is the pattern of the JSON/XML on CA SDM?

    Posted 12-09-2019 06:52 AM
    Hey guys. How are you?

    I'm facing problems with the pattern of the JSON when I try to create a new ticket..
    What i'm doing:

    POST -> http://{host}/caisd-rest/in
    with this json:


    {
      "in": {
           "@id": "U' {ID HERE}'",
           "@REL_ATTR": "U'{ID HERE}'",
           "@COMMON_NAME": "WEB",
           "description": "Descrição TESTE REST",
           "pcat": "401634",
           "summary": "Sumário via REST",
           "status": "OP",
           "customer": "U'{ID HERE}'",
           "type": "I",
           "priority": "3",
           "string6": "Cliente web externo",
           "z_local": "TJBA COSIS",
           "email_address": "teste1@tes.com",
           "customer.phone_number": "(75) 98933-6968",
           "z_alt_phone_number": "(71) 65665-6969",
           "zs_email_preferencial": "teste2@teste.com",
           "zs_oab": "985",
           "z_comarca": "400003",
           "z_cidade": "400003",
           "z_lotacao": "402981"
       }
    }

    I tried to do this with the XML and i'm getting the same 400 bad request

    <in>
        <customer id="U'{ID HERE}'" REL_ATTR="U'{ID HERE}'" COMMON_NAME="WEB_EXTERNO"/>
        <category id="U'{ID HERE}'" REL_ATTR="U'{ID HERE}'" COMMON_NAME="WEB_EXTERNO">401634</category>
        <customer.phone_number>(753433-6968</customer.phone_number>
        <description>Descrição TESTE REST XML</description>
        <email_address>teste1@tes.com</email_address>
        <log_agent  id="U'{ID HERE}'" REL_ATTR="U'{ID HERE}'" COMMON_NAME="WEB_EXTERNO"/>
        <priority>0</priority>
        <status>OP</status>
        <string6>Cliente web externo</string6>
        <summary>Sumário de Testes</summary>
        <type>I</type>
        <z_alt_phone_number>(713433-6969</z_alt_phone_number>
        <z_cidade>400002</z_cidade>
        <z_comarca>400002</z_comarca>
        <z_local>TJBA COSIS</z_local>
        <z_lotacao>402651</z_lotacao>
        <zs_email_preferencial>teste2@teste.com</zs_email_preferencial>
        <zs_oab>123</zs_oab>
    </in>



    I'm getting '400 bad request' code. Is there something that am I missing? Obs: I'm using POSTMAN to request. Is there some configuration on POSTMAN to make this work?

    Thank you for all!


  • 2.  RE: Which is the pattern of the JSON/XML on CA SDM?

    Posted 12-09-2019 07:44 AM
    Edited by Brian Mathato 12-09-2019 08:12 AM
    Hi Rafael,

    Are all the fields you are referencing part of the in object\factory? I don't recall seeing email_address on the in object before.

    Remove the following from the request and see what happens:

       "email_address": "teste1@tes.com",
        "customer.phone_number": "(75) 98933-6968",

    Otherwise, check the stdlog and\or jrest.log to see if there something you can pick up from there?



    ------------------------------
    Kind Regards,
    Brian
    ------------------------------



  • 3.  RE: Which is the pattern of the JSON/XML on CA SDM?

    Posted 12-10-2019 02:18 AM
    There's a couple of issues with your JSON payload:
    • Remove the ID, COMMON_NAME and REL_ATTR fields, you don't get to choose them when you create a ticket
    • Enter all REL fields as embedded objects in the JSON structure. I'm not 100% sure if they strictly MUST to be like that but I know it works so give it a go. See the example below.
    • Remove the customer fields like Brian suggested, you can't set them when creating a ticket
    {
      "in": {
           "description": "Descrição TESTE REST",
           "pcat": { "@ID":"401634" },
           "summary": "Sumário via REST",
           "status": { "@REL_ATTR": "OP" },
           "customer": { "@ID": "{ID HERE}" },
           ...
       }
    }


    Postman shouldn't need any specific configuration, all you need to do is to do the login with basic auth, extract the access key and id (for logout time) from it and then send the access key with the X-AccessKey header. Once you're done, call the DELETE /rest_access/<access_id> to logout. Just be aware that the internal logout implementation has a bug and it requires admin function access to work, otherwise you'll just have to leave the sessions hanging.




  • 4.  RE: Which is the pattern of the JSON/XML on CA SDM?

    Posted 12-10-2019 07:40 AM
    Thank you @Jussi Valkonen and @Brian Mathato for the answers!!!
    It helped me a lot to clarify somethings..
    I think i'm close to make it works.. i have just a little another question for you..

    My json is it:

    {
        "in": {
            "description": "Descrição TEST",
            "pcat": { "@ID":"401634" },
            "summary": "Sumário de Testes",
            "status": { "@REL_ATTR":"OP" },
            "customer": {"@id":"U'ID_HERE'"},
            "type": {"@REL_ATTR": "I"},
            "priority": {
                "@id": "505",
                "@REL_ATTR": "0",
                "@COMMON_NAME": "Nenhuma"
            },
            "string6": "Cliente web externo",
            "z_local": "TJBA COSIS",
            "z_alt_phone_number": "(71) 3653-65659",
            "zs_email_preferencial": "teste@teste.com",
            "zs_oab": "123",
            "z_comarca": {"@id":"400002"},
            "z_cidade": {"@id":"400002"},
            "z_lotacao": {"@id":"402651"}
        }
    }

    So I'm getting a bad request with the message: "Required Priority attribute is missing" but it is in my json. 
    ​​I tried so many different ways to solve this Priority attribute is missing and nothing until now.

    If i took out the "customer" attribute the message is:
    com.ca.sdm.dal.PersistenceException: INVALID: z_cr_sla.spl: 69:cr: :z_cr_sla


    Thank you for all!



  • 5.  RE: Which is the pattern of the JSON/XML on CA SDM?

    Posted 12-10-2019 07:58 AM
    Hi Rafael,

    For priority, the value of that gets stored in the call_req table is the enum field.So instead of '@id', you probably have to use '@enum'

    https://techdocs.broadcom.com/content/broadcom/techdocs/us/en/ca-enterprise-software/business-management/ca-service-management/17-2/reference/ca-service-desk-manager-reference-commands/objects-and-attributes/call-request-cr-object.html

    ------------------------------
    Kind Regards,
    Brian
    ------------------------------



  • 6.  RE: Which is the pattern of the JSON/XML on CA SDM?
    Best Answer

    Posted 12-11-2019 11:02 AM
    Hi @Rafael Oliveira,

    ​​Your JSON must looks like with

    { 
       "in":{ 
          "customer":{ "@id": "U'55E8D9CF4C8E554887715B07B7136C66'" },
          "category":{ "@id": "401634" },
          "customer.phone_number":"(75) 3333-3333",
          "description":"TESTE",
          "email_address":"teste1@tes.com",
          "priority":{ "@REL_ATTR": "1" },
          "status":{ "@REL_ATTR": "OP" },
          "string6":"McDonalds",
          "summary":"TESTE",
          "type":{ "@REL_ATTR": "I" },
          "z_alt_phone_number":"(71) 3333-3333",
          "z_cidade":{ "@id": "400002" },
          "z_comarca":{ "@id": "400002" },
          "z_local":"OAB - IMBUÍ",
          "z_lotacao":{ "@id": "402651" },
          "zs_email_preferencial":"jutai@mcdonald.com",
          "zs_oab":"12356"
       }
    }​