Field has invalid html content

8430
12
08-30-2017 09:17 AM
NathanHeick
Occasional Contributor II

Does anyone know the specific details about the above error message?  I receive it when I try to add features through the REST API for a hosted feature service in AGOL.  The features have a field with one or more HTML hyperlinks as shown below:

<a href="http://domain/custom/GISDrawingLookup.asp?drawingNo=JO-P-0293&searchName=JO-P-0293" target="_blank">JO-P-0293</a>,<br><a href="http://domain/custom/GISDrawingLookup.asp?drawingNo=JO-P-0004&searchName=JO-P-0004" target="_blank">JO-P-0004</a>

The REST API does not like the & and = characters in the URLs.  It does not complain about the HTML, just the use of URL parameters.  When publishing the service from ArcMap, the data is loaded as is into the hosted feature service and displays perfectly.  I have several workarounds ready, but I would like to get the REST API to work using the addFeatures endpoint.  I need to automate updating the service and I would prefer to avoid republishing the service each time, or using Arcade and custom HTML popups.

Thanks,

Nathan

12 Replies
dmacq
by
New Contributor III

We're having the same issue when trying to update a hosted feature service in AGOL using Python. It also appears to be causing issues when copying content in AGO Assistant. Any luck with this?

0 Kudos
NathanHeick
Occasional Contributor II

Yes, I was able to update the hosted feature service using Python, but I had to republish the service each time from an MXD.  This process is fairly involved.  You have to create a service definition draft, analyze it, generate a service definition, upload the service definition to ArcGIS Online, republish the service from the service definition, and reapply the service item info and item data to the overwritten service.  Creating the service definition draft involves arcpy.mapping and modifying XML.  To make the primary REST API requests, you have to make many other requests to look up the service and service definition item ids, item info, item data, item metadata, item folder id, and item folder name based on the service name.  Uploading the service definition is a multipart asynchronous process.  Publishing the service definition is also an asynchronous process that multiple REST calls.  Finally, when you overwrite the service definition and service items, you lose most of the item info, item data, and metadata in the process.  This requires more REST calls to reapply that information to the new service definition item and the updated service item.  This is necessary to retain your popup configurations, item descriptions, and any item properties you usually set in AGOL.

Also, the AGOL Assistant probably uses the same REST endpoint (applyEdits) to update item data, so it makes sense you would get the same issue.

Thanks,

Nathan

0 Kudos
dmacq
by
New Contributor III

Thanks, Nathan.

I'm not sure if this applies to your workflow. I'm adding and updating features using the ArcGIS API for Python to updated hosted feature layers on AGOL. Specifically, I'm using the edit_features method. 

In my case, I narrowed the issue down to "=" in quoted URL strings. For instance, the "=" characters in this part of your string drawingNo=JO-P-0004&searchName=JO-P-0004 would have caused my script to fail. I replaced them with "%3D", and the script is running fine. I also had some unsupported tags that I had to take care of, and I'm still doing some testing, but that was my major hangup, and I've been able to move forward since fixing it. 

NathanHeickLACSD
Occasional Contributor III

Yes, it has been a little while since I worked on this issue.  I do remember that the main issue was the equals signs in the URLs.  I suspect they are identifying URL parameters as a potential security threat.  I believe that I also escaped the equals signs and that fixed the issue.  In the end, for other reasons, I decided to go with using the ArcGIS REST API to republish the service the same way ArcMap does.  It might have been because of unsupported HTML tags.  Underneath it all, the ArcGIS API for Python uses the ArcGIS REST API, so knowledge like this applies no matter how you use it.  I just wish I could have found the restrictions in the documentation somewhere.

0 Kudos
KarenRobine1
New Contributor III

This is an old post but I just ran into this and found the solution.  In the Advanced Feature Access settings in ArcGIS Server (under Capabilities), you need to make sure you uncheck the box that says Filter web content.  I had this set for one of my services, and was unable to edit any HTML-based content in my string fields.  As soon as I turned it off, it all worked.  Not necessary to escape the HTML. 

MichaelAugust
Occasional Contributor III

Thank you! This was driving me nuts, honestly never even went into advanced settings before.  This was very helpful.

0 Kudos
PeterMilenkovic
Occasional Contributor

FYI for anyone else having this issues with AGOL hosted layers, there is a post that describes how to update setting's at the FeatureServer level here

https://comunity.esri.com/t5/arcgis-data-interoperability-blog/writing-html-and-other-amp-lt-and-amp... 

 

ChadPeltier
New Contributor II

For future users - the link has changed: Writing HTML and other &lt; and &gt; tagged conten... - Esri Community 😁

0 Kudos
BillSouter2
New Contributor II

I recently encountered this error in ArcGIS Online using Python to copy data using REST. The issue turned out to be that a user had added the text "<Null>" into a text field in an enterprise geodatabase.

My theory is that the ArcGIS Online html validation treats the text as an unrecognized html tag and rejects the record and I can replicate the error by trying to add the text "<Null>" into the Data widget in ArcGIS Online.