Home Analyst Portal

Announcement API Example for how to use the UpdateAnnouncement

Jan_SchulzJan_Schulz Customer Adept IT Monkey ✭✭

Hi,

i cant get this API function to work.

I want to create and update announcements in the Cireson Portal with the API.

But i only get an not specific error.

System.NullReferenceException: Object reference not set to an instance of an object.

Can somebody give me a hint which body i have to use on the POST Method UpdateAccouncement.

i used the following to update a already created announcement which i get from the getAllAnnouncements function.

{

 "Id": "53580ff5-04a7-4466-b904-8aa9e1796d5b",

 "Title": "sample string 2",

 "Priority": "Gering",

 "PriorityId": "ead45490-625e-4adf-8f4c-0e18dbce2b66",

 "Body": "sample string 5",

 "AccessGroupId": "a2522949-8a9b-e8b2-f2b9-751602a75377",

 "StartDate": "2022-04-28T15:01:59.791Z",

 "EndDate": "2022-04-30T15:01:59.791Z"

}

regards,

Jan

Best Answer

  • Shane_WhiteShane_White Cireson Support Super IT Monkey ✭✭✭✭✭
    Accepted Answer

    Hi Jan,

    Glad to hear you are working with some of the API's in the portal, I think I might know the issue you are having, so:

    1. Priority takes a NameIdModel, so should be an object that looks like: {"Id":"f10a51c2-c569-4e64-8237-2b117d63ddb8","Name":"Critical"}
    2. AccessGroupId is the same, it is also a NameIdModel, so would look like: {"Id":"3150dd4a-3216-3847-4eec-7c3bc9b32adf","Name":"Domain Users"}
    3. Below is an example that I used in the Dev tools to create an announcement, then to update you just ensure the Id is the same and you can then change the other fields for updates

    $.ajax({

      url: '/api/V3/Announcement/UpdateAnnouncement',

        type: 'POST',

    contentType: 'application/json',

    data: JSON.stringify({

    "Id":"60d1d6e7-916f-41b4-b8b6-f321c9c97b5d",

    "Title":"Test API for Jan",

    "Priority":{"Id":"f10a51c2-c569-4e64-8237-2b117d63ddb8","Name":"Critical"},

    "Body":"Test API for Jan",

    "AccessGroupId":{"Id":"3150dd4a-3216-3847-4eec-7c3bc9b32adf","Name":"Domain Users"},

    "StartDate":"2021-04-28T23:00:00.000Z",

        "EndDate":"2021-04-29T23:00:00.000Z",

    "Locale":"ENU"

    }),

        dataType: 'json'

    });

    Thanks,

    Shane

Answers

  • Shane_WhiteShane_White Cireson Support Super IT Monkey ✭✭✭✭✭
    Accepted Answer

    Hi Jan,

    Glad to hear you are working with some of the API's in the portal, I think I might know the issue you are having, so:

    1. Priority takes a NameIdModel, so should be an object that looks like: {"Id":"f10a51c2-c569-4e64-8237-2b117d63ddb8","Name":"Critical"}
    2. AccessGroupId is the same, it is also a NameIdModel, so would look like: {"Id":"3150dd4a-3216-3847-4eec-7c3bc9b32adf","Name":"Domain Users"}
    3. Below is an example that I used in the Dev tools to create an announcement, then to update you just ensure the Id is the same and you can then change the other fields for updates

    $.ajax({

      url: '/api/V3/Announcement/UpdateAnnouncement',

        type: 'POST',

    contentType: 'application/json',

    data: JSON.stringify({

    "Id":"60d1d6e7-916f-41b4-b8b6-f321c9c97b5d",

    "Title":"Test API for Jan",

    "Priority":{"Id":"f10a51c2-c569-4e64-8237-2b117d63ddb8","Name":"Critical"},

    "Body":"Test API for Jan",

    "AccessGroupId":{"Id":"3150dd4a-3216-3847-4eec-7c3bc9b32adf","Name":"Domain Users"},

    "StartDate":"2021-04-28T23:00:00.000Z",

        "EndDate":"2021-04-29T23:00:00.000Z",

    "Locale":"ENU"

    }),

        dataType: 'json'

    });

    Thanks,

    Shane

  • Jan_SchulzJan_Schulz Customer Adept IT Monkey ✭✭

    Hi Shane,


    thank you for your help :-).

Sign In or Register to comment.