CA Service Management

  • 1.  Update Contact Record using REST

    Posted Jul 20, 2017 09:57 AM

    Hello,

     

    I'm trying to formulate the body of a put method to update contact attributes using REST, so far I have an xml string formatted like this:

    string putBody = @"<cnt>" + "<billing_code>cost_cntr:1000072</billing_code>" + "</cnt>";

    The call doesn't fail, the cost center field on the record just gets set to blank. This is the format that works with soap but I can't figure out how it needs to be modified to work with REST?

     

    The line below works but that's updating a simple string attribute on the object itself not an SREL to another object.

    //string putBody = @"<cnt>" + "<last_name>HelloWorld</last_name>" + "</cnt>";

     

    Can someone point me in the right direction on handling SRELs with REST?

     

    Elwynn.



  • 2.  Re: Update Contact Record using REST

    Broadcom Employee
    Posted Jul 20, 2017 10:40 AM

    with this schema:

    billing_code         SREL -> cost_cntr.id

    I think you should use

    <billing_code>1000072</billing_code>

    not

    <billing_code>cost_cntr:1000072</billing_code>



  • 3.  Re: Update Contact Record using REST

    Broadcom Employee
    Posted Jul 20, 2017 10:42 AM


  • 4.  Re: Update Contact Record using REST

    Posted Jul 20, 2017 01:49 PM

    Chi,

     

    I tried taking out the object reference as you mentioned but it still sets cost center to blank on the contact record.

     

    I also noticed that I hadn't used the X-Obj-Attrs: header either so I added that in but still with no effect.

     

    So I tried all 4 different combinations of the object reference and header but with no luck. Do I need to declare a type like your example shows in the other thread?

     

    Elwynn.



  • 5.  Re: Update Contact Record using REST

    Broadcom Employee
    Posted Jul 20, 2017 03:34 PM

    Elwynn, I don't think so...that is for BREL and this one is SREL. Let me see if I can find an env try to do a similar one there. Thanks _Chi



  • 6.  Re: Update Contact Record using REST

    Broadcom Employee
    Posted Jul 20, 2017 05:31 PM

    this one works for me:

    <billing_code REL_ATTR=\"1000072\"/>



  • 7.  Re: Update Contact Record using REST

    Posted Jul 21, 2017 11:52 AM

    Chi,

     

    I'm still trying to figure out how to get your example to work, can you give me a bit more of the code?

    Also what tool where you using when you got the above format to work? I'm working with C# and can't figure out how to get double quotes within a string that already has double quotes.

     

    Elwynn.



  • 8.  Re: Update Contact Record using REST
    Best Answer

    Broadcom Employee
    Posted Jul 21, 2017 12:02 PM

    Elwynn, I used java...and I constructed the variable as this:

    PutMethod put = new PutMethod(endpointPUT);
            put.addRequestHeader("X-AccessKey", accessKey);
            put.addRequestHeader("Accept" , "application/xml");
            put.addRequestHeader("Content-Type", "application/xml; charset=UTF-8");
            put.setRequestBody(
                    "<cnt>" +
                    "<billing_code REL_ATTR=\"1000001\"/>" +
                    "</cnt>"
            );

    /////////////////////////////////////////////

    As for C#, I think you can do the same using \" to escape. Please take a look at C# in Depth: Strings in C# and .NET 

    Thanks _Chi



  • 9.  Re: Update Contact Record using REST

    Posted Jul 21, 2017 01:18 PM

    Chi,

     

    I finally got it to work, by copying and pasting your code exactly.

    Thanks for your help!

     

    Elwynn.