Add a view using Configuration API can' t holding view groups on Smart Client?

I’ d like to submit question about “CreateView.zip” which is featured in the article below published in the days of VMS 2021R1.

[Article] Add a view using Configuration API strongly typed classes.

https://developer.milestonesys.com/s/article/Add-a-view-using-Configuration-API-strongly-typed-classes

I am using VMS 2023R3.

Procedure:

Step1. I unzipped “CreateView.zip” and executed it in Visual Studio 2019.

(Following the note written in the article, the camera’s GUID has been changed to my camera’s GUID)

Step2. After execution, I opened the MIPSDK (for 2023R3) sample “ConfigApiClient” and checked the “View groups” tree.

Step3. Then, the view group (Main: CreateViewTestTopGroup and Sub: CreateViewTestSubGroup) defined in Step 1 has been added.

However, something strange is happening as shown below.

- When I open Smart Client, only the view group (Main: CreateViewTestTopGroup) is displayed, and the view group (Sub: CreateViewTestSubGroup) is not displayed.

- On the other hand, if I execute “CreateView.exe” while open and viewing Smart Client, the view group (Main: CreateViewTestTopGroup and Sub: CreateViewTestSubGroup) displaying at this time. But when I restart Smart Client, the view group (Sub: CreateViewTestSubGroup) is not visible.

How can I persist view groups in Smart Client through “CreateView.exe”?

CreateView.exe, Smart Client, and the MIPSDK sample “ConfigApiClient”, they were all logged in as the same user with admin privileges.

Of course, I’m understanding that I can use the MIPSDK sample “ConfigApiClient” to add views without using Smart Client.

However, I am very impressed with CreateView.exe, which allows to create view groups by simply clicking on the exe file.

I will experiment with the old ‘sample’ and let you know what I find..

Dear Bo,

Thank you for your investigation.

I did one modification thinking that this sample was very old. I inspected the .csproj file and changed

 <Version>21.1.0</Version>

to

 <Version>\*</Version>

this to make sure I do not use a very old MIP SDK!

Using the sample I was able to confirm your observations and I believe there is a bug. I will ask Milestone Development to investigate.

While Development investigates I have a temporary workaround. If I add this line of code just after the initialize..

VideoOS.Platform.SDK.Environment.Initialize();
VideoOS.Platform.Configuration.Instance.ConfigurationApiManager.UseRestApiWhenAvailable = false; // added 

it works! The line introduces a fallback for older functionality, and please use this only temporarily until Milestone has a fix.

Dear Bo,

Thank you for your investigate.

I tried to make groups that you mentioned procedure.

Yes, I confirm that it works to make groups !

I appreciate you.

Next, I tried to put in view two Camera using “PutInViewTwoCameraItems” method you created in 2021.

However, it happened exception error at “view.Save()”.

I share you error log in below.

----------------------------------------------------------------------------------

VideoOS.Platform.ArgumentMIPException

HResult=0x80131500

Message=PATCH Unexpected statuscode BadRequest in ‘http://(MyServerAddress)/API/rest/v1/views/68223519-8836-4f15-86bf-220acc877536’ - Invalid xml

Source=VideoOS.Platform

InternalException1:

RestApiMIPException: PATCH Unexpected statuscode BadRequest in ‘http:// (MyServerAddress)/API/rest/v1/views/68223519-8836-4f15-86bf-220acc877536’ - Invalid xml


I think there’s an impact through change RestApi.

But I ‘m not sure that knowing RestApi so I can’t say more than this.

Can you reproduce this exception error?

No, I cannot reproduce.

To me this error sounds impossible if you added the “UseRestApiWhenAvailable = false”

Please double-check the camera GUIDs, see that they work when in the CreateViewItemDefinitionXml method.

You use XProtect VMS 2023R3, can you confirm you use the MIP SDK 2023R3 NuGets to build?

Dear Bo,

Thank you for checking your confirmation.

>You use XProtect VMS 2023R3, can you confirm you use the MIP SDK 2023R3 NuGets to build?

Yes, I using MIP SDK 2023R3 NuGets to build. Its version is 23.3.2.

I’ d like to share you my investigation.

I think it’s no relative between this exception error and “UseRestApiWhenAvailable = false”.

It seems to happen when I tried to registering Camera including “&” in Camera name.

When I testing before this article I wrote, I registered camera that no including “&” in Camera name and No exception error.

There’s no issue when I registered manually in Smart Client.

Therefore, I think it’s bug in MIP SDK.

Can you please reproduce same issue?

I reproduce in below steps.

1. Open Management Client 2023R3.

2. Click as below

Site Navigation > Servers > Recording Servers > (Server Name) > (Device Name) > (Camera Name)

3. Click [Info] tab in the right.

4. Change Camera name to including “&” at [Device information].

5. Save and restart VMS.

Yes, I can reproduce with these new instructions. I guess the key here is the camera name including a “&”. Please workaround making sure you do not use “&”.

Thank you for reporting this issue. I will report the issue to Milestone Development.

Dear Bo,

Thank you for checking your confirmation.

I look forward to the MIP SDK improving.

Big thanks, Mr. Bo!!

The solution is:

string noAmp = cameraItem.Name.Replace("&", "&amp;");            // only ampersand
string noSp = new System.Xml.Linq.XText(cameraItem.Name).ToString();   // general XML escape handling

Place and use this in the right spot at CreateViewItemDefinitionXml in the sample.

You must do this or the XML parser will fail and you will see the exception.

Dear Bo,

Thank you for shareing me about the escape character conversion process.

I added System.Xml.Linq.XText conversion at CreateViewItemDefinitionXml in the sample.

It works!!

In addition, I added the following processing.

cameraName = cameraName.Replace("\"", """);

Apparently, escape character “”" is not taken care in System.Xml.Linq.XText conversion.