Select to view content in your preferred language

Point gets added without Attachments using ArcGIS Runtime Xamarin (100.14.1)

747
3
10-07-2022 05:10 AM
GurminderBharani3
New Contributor

Hi Team, 

I am using ArcGIS Runtime 100.14.1

Screenshot 2022-10-07 at 5.30.24 PM.png

I have a public ArcGIS Feature Server with Attachments enabled. 

Using the rest interface I am able to add attachments to existing points. 

Dummy Sample URL: https://domain.com/arcgis/rest/services/ProdFolder/DataCollect/FeatureServer/0/1/addAttachment

However in my Runtime code I am using AddAttachmentAsync with all the correct parameters.

I do not get any exceptions and the point gets added successfully.

When I check the Map in ArcGIS Online map viewer I do not see the attachments.

Screenshot 2022-10-07 at 5.32.40 PM.png

Is this a known issue? 

Any suggestions would be very helpful. 

public async void AddAttachmentImageInFeature()
        {
            try
            {
                var popupResult = new AddAttachmentModel { filemodelList = null, };
                var result = await Navigation.ShowPopupAsync(new AddAttachmentsPopUpPage(popupResult));
                if (result != null)
                {
                    UserDialogs.Instance.ShowLoading();
                    if (_selectedFeature.CanEditAttachments)
                    {
                        try
                        {
                            foreach (var item in result.filemodelList)
                                await _selectedFeature.AddAttachmentAsync(item.filename, item.contenttype, item.applicationData);
                            ServiceFeatureTable serviceTable = (ServiceFeatureTable)_selectedFeature.FeatureTable;
                            await serviceTable.ApplyEditsAsync();
                            _selectedFeature.Refresh();
                            feature.Refresh();
                            UserDialogs.Instance.HideLoading();
                            await Xamarin.Forms.Application.Current.MainPage.DisplayAlert("Success!", "Successfully added feature and attachment", "OK");
                        }
                        catch (Exception e)
                        {
                            Console.WriteLine(e);
                        }
                    }
                    // Create and remove a graphic from the geometry the user drew
                    if (Helpers.Constant.selectedLayer.name == "AOI Polygon" || Helpers.Constant.selectedLayer.name == "AOI Lines")
                    {
                        Graphic graphic = CreateGraphic(Polygonegeometry);
                        _sketchOverlay.Graphics.Clear();
                        _sketchOverlayforfeature.Graphics.Clear();
                    }
                    CompleteButton.IsVisible = false;
                    AddButton.IsVisible = false;
                    UnduButton.IsVisible = false;
                    IsDrawStart = false;
                    linePoints.Clear();
                }
                else
                {
                    // Create and remove a graphic from the geometry the user drew
                    if (Helpers.Constant.selectedLayer.name == "AOI Polygon" || Helpers.Constant.selectedLayer.name == "AOI Lines")
                    {
                        Graphic graphic = CreateGraphic(Polygonegeometry);
                        _sketchOverlay.Graphics.Clear();
                        _sketchOverlayforfeature.Graphics.Clear();
                    }
                    _selectedFeature.Refresh();
                    feature.Refresh();
                    CompleteButton.IsVisible = false;
                    AddButton.IsVisible = false;
                    UnduButton.IsVisible = false;
                    IsDrawStart = false;
                    linePoints.Clear();
                }
            }
            catch (Exception exception)
            {
                await Xamarin.Forms.Application.Current.MainPage.DisplayAlert("Error adding attachment", exception.ToString(), "OK");
            }
        }

Best regards,

Gurminder

 

 

0 Kudos
3 Replies
MichaelBranscomb
Esri Frequent Contributor

Hi,

Can you share the code where you're creating/updating the feature and attachment, adding to the table, and applying the edits to the service?

 

Thanks

0 Kudos
GurminderBharani3
New Contributor

@MichaelBranscomb I have updated my post with the code. 

0 Kudos
MichaelBranscomb
Esri Frequent Contributor

I have not been able to reproduce this, although without the full code / repro my repro would be different from your exact case.

I recommend taking a look at our sample code for EditFeatureAttachments and comparing that with your app logic.

 

0 Kudos