Select to view content in your preferred language

FeatureLayer.applyEdits() adding empty attachments object to request, causing error to be returned

1925
8
Jump to solution
01-03-2020 11:44 AM
JamesGough
Regular Contributor

This is in an application using React and esri-loader to load the latest ArcGIS JS API version (4.14).

The editing is on a hosted feature service on our Portal (10.7.1).

    /**
     * Add graphic to the reported Incidents feature layer
     */
    confirmAdd = () => {
        this.reportedIncidents.applyEdits({
            addFeatures: [this.newIncidentGl.graphics.getItemAt(0)]
        }).then(function(results){
            console.log(results);
        }).catch(function(error){
            console.log(error)
        });
        this.setShowConfirmFalse();
    }‍‍‍‍‍‍‍‍‍‍‍‍‍

The code falls through to the catch block where an error is returned with this message: 

message: "JSONObject["publishInfo"] not found."

Even though this error is returned the feature is still created in the feature class.

I determined through some testing that this error was being caused because the JS API was passing attachments in the request. Example request form data from Network activity in dev console:

f: json
adds: [{"geometry":{"spatialReference":{"latestWkid":3857,"wkid":102100},"x":-8560006.330198715,"y":4734542.560828083},"attributes":{"incidentty":"Water Main Break","incidentde":"","customerna":"","contactno":"","searchedad":"GPS Location Used"}}]
attachments: {"adds":[],"updates":[],"deletes":[]}‍‍‍

The only fix I have found for this is to intercept the request with esriConfig.request.interceptors and remove the attachments object from the query:

esriConfig.request.interceptors.push({
    urls: featureApplyEditsUrl,
    before: (params) => {
        if(params.requestOptions.query.attachments){
            delete params.requestOptions.query.attachments
        }
    }
})‍‍‍‍‍‍‍‍

If I do this, then the applyEdits operation is successful and does not return an error, and I get the edit results returned in the .then function.

So is this a bug in the API? An issue with my feature service? An issue with how I am calling applyEdits?

EDIT: I tested loading 4.13 instead of 4.14 and the error went away. At 4.13 the API does not pass the attachments object when no attachments are specified. So this seem to be an issue at 4.14

0 Kudos
1 Solution

Accepted Solutions
UndralBatsukh
Esri Regular Contributor

Hi there, 

Thank you for bringing this issue to our attention. We will get this issue fixed at next release! 

Thanks,

-Undral

View solution in original post

0 Kudos
8 Replies
UndralBatsukh
Esri Regular Contributor

Hi there, 

Thank you for bringing this issue to our attention. We will get this issue fixed at next release! 

Thanks,

-Undral

0 Kudos
JamesGough
Regular Contributor

Hi Undral,

Thanks for the response. I will mark this as answered since you are confirming that this it is a bug.

Thanks,

James

0 Kudos
ChristopherDufault
Esri Contributor

Undral has this been verified fixed as of 4.15? 

0 Kudos
UndralBatsukh
Esri Regular Contributor

Yes it is fixed at 4.15.

0 Kudos
UndralBatsukh
Esri Regular Contributor

Hi there, 

I apologize for my hasty response yesterday. I spent some time investigating this issue and  am not able to reproduce the issue described here. I created a simple test app that I think showcases your workflow. Can you please take it? Can your service with me? Seems like the issue is related to the service/server settings. 

Thanks,

-Undral

0 Kudos
JamesGough
Regular Contributor

Undral,

I switched the service in your linked example code with my feature service and got the same error (again only at v4.14 of the api). However, If enable attachments on the feature service, then I do not get the error.

So it seems that if you do not have attachments enabled then you will get this error when using applyEdits since it is automatically sending that attachments parameter in the request.

0 Kudos
UndralBatsukh
Esri Regular Contributor

Hi there, 

Thank you for the additional information. It is much appreciated. I was able to reproduce the issue with ArcGIS Portal 10.71 feature services (the issue is specific to this version). We will get this fixed at 4.15. 

Thanks again for the detailed information.

-Undral

0 Kudos
JamesGough
Regular Contributor

Thanks for taking the time to look into it. Glad I could help.

James

0 Kudos