"Object reference not set to an instance of an object" when updating AGOL Feature Service via Append Data function

16378
9
02-15-2018 03:03 PM
DarrenBeckstrand
New Contributor

I'm working in AGOL, trying to use the relatively new "Append Data to Layer" tool under the "Update Data" section in the Overview tab of a hosted feature layer to add new data to my hosted feature layer.  I have previously used this function to batch append multiple new entries to a point layer, using a zipped file geodatabase, and it was pretty slick.  Now I want to "upsert" additional data collected at each of these locations, i.e. add new data to existing features, instead of adding new features.  I added fields to my existing database in AGOL, but when I try to "update existing features" using a compressed file geodatabase, I get the following error message: "Error: object reference not set to an instance of an object."

If I use a CSV file, the upsert works, but since one of the new data fields includes comments with commas, I don't want to incorporate this into our workflow going forward.

If I use a compressed Shapefile, the upsert also works, but due to the character limit in shapefile field names, field matching during the Append Data process takes extra work, so again, I'd like to avoid putting this into the permanent workflow if possible.

Any advice for how to get upserts to work with a compressed file geodatabase in AGOL?  I have an AGOL Basic license.

I'm matching "ObjectID" to "ObjectID_Orig," a field I created to ensure the unique identifiers were tying the new data to the existing data like I wanted them to. I've checked the area extents and projection.  All the settings in the file geodatabase that I've compressed look identical to the one that I successfully used to append new features last week, just with a couple dozen new fields.  I referred to an ESRI blog post when getting started with this function, but it's not much help now that I'm troubleshooting. (What’s new with hosted feature layers: Getting to know Append, Part 2 | ArcGIS Blog)

0 Kudos
9 Replies
KellyGerrow
Esri Frequent Contributor

Hey Darren,

It sounds like there is some sort of mismatch in the data. We are working on improving the error messages in an upcoming release. I'd suggest getting in contact with support to dig into the issue a little deeper. 

For some quick troubleshooting steps, run the check geometry tool in ArcGIS Pro or ArcMap to ensure that the geometries are valid.

Check the data for duplicate records, item IDs, etc.

Please post back if you are able to narrow it down further.

-Kelly

0 Kudos
DarrenBeckstrand
New Contributor

Hi Kelly,

Thank you for your recommendations.  I ran the check geometry tool in ArcMap when I first ran into this issue, and as far as I can tell, nothing came up.  I also didn't see any duplicate records. 

My work flow has run as follows:

- export point layer data from AGOL,

- use a join to add new data and fields to the existing points,

- export this data as a new layer to a file geodatabse,

- zip and attempt to upload. 

If I export the new layer to a shapefile, zipping and upserting go just fine. At this point, I can make the shapefile method work, so I've moved on to other things.  If error messages are improved in the new release, I can try this all again.  Is there a specific group in support that I should reach out to?

Thank you,

Darren

0 Kudos
KellyGerrow
Esri Frequent Contributor

Hi Darren,

Try contacting support and let them know you are working with ArcGIS Online. They will get you to a knowledgeable analyst.

Esri Support Contact Support 

-Kelly

0 Kudos
MichaelKelly
Occasional Contributor III

I encountered this when the date fields weren't formated properly in the .csv file I was uploading.

When I changed them to use the following format it worked:

dd/mm/yyyy 17:00:00

08/11/2018 17:00:00

A good way to error check this is by deleting fields which you think may be causing problems from the .csv file, and uploading again.

I have asked a question to see whether there is a 'recommended' way for formatting dates when appending like this.

0 Kudos
DarrenBeckstrand
New Contributor

Thanks for that advice.  I haven't had any problems with appending .csv data, but not it's one more thing to check if that's an issue managing other datasets.  There is date information in the geodatabase, but I haven't made any edits to that data relative to the original dataset.  That said, I'll be getting a new batch of data in about a month, so I can test the date issue then.

0 Kudos
beckhayer
New Contributor

An Object is an instance of a Class , it is stored some where in memory. A reference is what is used to describe the pointer to the memory location where the Object resides. The message "object reference not set to an instance of an object" (NullReferenceException) means that you are referring to an object the does not exist or was deleted or cleaned up. In order to prevent the error, objects that could be null should be tested for null before being used.

if (mClass != null)
{
// Go ahead and use mClass
mClass.property = ...
}
else
{
// Attempting to use mClass here will result in NullReferenceException
}

A NullReferenceException typically reflects developer error and is thrown in the following scenarios:

  • Forgotten to instantiate a reference type.
  • Forgotten to dimension an array before initializing it.
  • Is thrown by a method that is passed null.
  • Get a null return value from a method, then call a method on the returned type.
  • Using an expression to retrieve a value and, although checking whether the value is null.
  • Enumerating the elements of an array that contains reference types, and attempt to process one of the elements.

 

0 Kudos
GJameson
New Contributor

Hey Darren -

This may be relevant to others who have this error occur. Look through your fields and double check uniques and nulls. Your data may be causing the database from adding the data in because of the parameters you've set. I received this error when adding data into a utility network after I added a few fields with unique values turned on. This caused my 6,200 records to not be added.

Hope this helps someone,

-Greg J.

PhilLarkin1
Occasional Contributor III

A comment 4 years after might not help the OP, but might help others.

I experienced this error during an append that was stopped prematurely.  As a result, orphaned records remained in the Hosted Feature Service (HFS). This wasn't immediately obvious because the Data tab of the HFS's item page was showing 0 records (as expected, this was post truncate). I had to extract and download the HFS as a file geodatabase to see that half of the records still remained. There was no way to clear out these records in AGOL or the Python API for AGS, so I had to delete the HFS and start over.

0 Kudos
ahargreaves_FW
Occasional Contributor III

My comment comes 5 yrs later but it helped resolve this issue. I simply had a required field set to not be visible while publishing from pro. Turning all field to visible resolved this issue for me. I then simply deleted the unneeded field in the AGOL HFS.

0 Kudos