Setting a Feature attribute value of a Blob field type : NotSupported

460
3
Jump to solution
12-07-2023 11:51 AM
Labels (1)
PierreMasson
Occasional Contributor

Hi,

We have published a Feature Service containing data and some of the fields are FieldType.Blob.

When we get the data using the ArcGIS MAp SDK we have no problem reading the field and using it. But if we want to set it`s value I get this exception:

System.NotSupportedException
The data type System.Byte[] is not supported.
at Esri.ArcGISRuntime.Data.CoreElementExtensions.SetAttributeValue(CoreElement element, Object value)
at Esri.ArcGISRuntime.Internal.AttributeDictionary.set_Item(String key, Object value)

I was passing a byte[]. So I checked the type of the attribute. It says ReadOnlyCollection<byte>. So I tried to set the value by transforming my byte[] to a ReadOnlyCollection<byte> and I get the same exception.

Si is it a SDK limitation? Is it just for now and later on it will be supported? Or is there something I can do differently to make it work?

These fields holds some serialized json transformed to byte[]. It was the best way we found to store large value in a field without having to set a field length. In SQL Server I would have used nvarchar(MAX) and store the json in text. Is there a better way to do that in ArcGIS/ArcGIS Online?

Thank you in advance.

0 Kudos
1 Solution

Accepted Solutions
williambohrmann3
Esri Contributor

Hi @PierreMasson - this is not supported at the moment. Feel free to contribute this idea on ArcGIS Maps SDKs Native Ideas 

View solution in original post

0 Kudos
3 Replies
williambohrmann3
Esri Contributor

Hello @PierreMasson, thank you for your question. Would you kindly answer the following to better help me understand your issue?

  1. Any reproducer code?
  2. Which version of ArcGIS Maps SDK are you using?
  3. What version of .NET are you using?

It seems like this is the first time you've attempted this workflow, using a Blob field with our SDK?

Thanks,
William

0 Kudos
PierreMasson
Occasional Contributor

Try to update the fields CanLiteConfigPACP, CanLiteConfigMACP, QCardConfigMACP or QCardConfigPACP of the feature here https://services6.arcgis.com/iLx36dZM4ZchIav8/ArcGIS/rest/services/SAM_20231221/FeatureServer/4

To answer your questions:


  1. byte[] byteValue = System.Text.Encoding.UTF8.GetBytes(stringValue);
    myFeature.SetAttributeValue("QCardConfigPACP", byteValue);

    Then I get 
    System.NotSupportedException
    The data type System.Byte[] is not supported.
    at Esri.ArcGISRuntime.Data.CoreElementExtensions.SetAttributeValue(CoreElement element, Object value)
    at Esri.ArcGISRuntime.Internal.AttributeDictionary.set_Item(String key, Object value)

  2. Esri.ArcGISRuntime 200.2.0
  3. .Net 6

 

I can easily update the field using the web UI and passing a base64 string. Using the SDK, I can then read the value this way:

string base64String = System.Text.Encoding.Default.GetString(((IList<byte>)(Feature.GetAttributeValue("QCardConfigPACP"))).ToArray());
byte[] bytes = Convert.FromBase64String(base64String);
return System.Text.Encoding.UTF8.GetString(bytes);

But I can't write the attribute value. 

Please help

0 Kudos
williambohrmann3
Esri Contributor

Hi @PierreMasson - this is not supported at the moment. Feel free to contribute this idea on ArcGIS Maps SDKs Native Ideas 

0 Kudos