Transferring Survey123 data with clone_items() fails due to XML parsing

1396
2
Jump to solution
05-10-2021 01:36 PM
gvanderwaal
New Contributor II

I'm attempting to transfer Survey123 data from ArcGIS Online to our Enterprise Portal. I have been attempting to use the "Clone_Survey_Content_Full_Folder" script linked here. It successfully transfers all data except the survey form itself. The error(s) it fails at are at the bottom of this post.

Line 14, column 61 of _replace_form's xml_string is the red line in this screenshot:

gvanderwaal_0-1620677352681.png

Pasting the contents of xml_string into an online XML validator confirms an error at 14:61. I assume ElementTree wants the </label> to be to the right of <label class> or to not exist at all, because doing either in said XML validator shifts to a new error at line 22:71, also caused by a an out-of-place </label>.

I'm hoping this is something resolved by changing software versions or something similarly easy.

ArcGIS Pro/ArcMap not installed locally
ArcGIS Enterprise/Portal 10.8.1
Python 3.9.5 64-bit
ArcGIS API 1.8.5.post3 installed via pip

@ZacharySutherby 

Traceback (most recent call last):
  File "C:\Users\user\AppData\Local\Programs\Python\Python39\lib\site-packages\arcgis\_impl\common\_clone.py", line 3104, in update_form
    payload['form'] = self._replace_form(form, field_mapping)
  File "C:\Users\user\AppData\Local\Programs\Python\Python39\lib\site-packages\arcgis\_impl\common\_clone.py", line 2944, in _replace_form
    xml = ElementTree.fromstring(xml_string)
  File "C:\Users\user\AppData\Local\Programs\Python\Python39\lib\xml\etree\ElementTree.py", line 1347, in XML
    parser.feed(text)
xml.etree.ElementTree.ParseError: mismatched tag: line 14, column 61

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\user\AppData\Local\Programs\Python\Python39\lib\site-packages\arcgis\_impl\common\_clone.py", line 3006, in clone
    self.update_form(self.target, new_item, self._clone_mapping)
  File "C:\Users\user\AppData\Local\Programs\Python\Python39\lib\site-packages\arcgis\_impl\common\_clone.py", line 3181, in update_form
    raise Exception("Failed to update {0} {1}: {2}".format(new_item['type'], new_item['title'], str(ex)))
Exception: Failed to update Form IA-OA Sampling Form V2: mismatched tag: line 14, column 61

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\workspace\Clone_Surveys\Clone_Survey_Content_Full_Folder-mod.py", line 70, in <module>
    cloned_items = target.content.clone_items(items=fldr_items, folder=fldr['title'])
  File "C:\Users\user\AppData\Local\Programs\Python\Python39\lib\site-packages\arcgis\gis\__init__.py", line 5517, in clone_items
    return deep_cloner.clone()
  File "C:\Users\user\AppData\Local\Programs\Python\Python39\lib\site-packages\arcgis\_impl\common\_clone.py", line 813, in clone
    results = executor.submit(self._clone, executor).result()
  File "C:\Users\user\AppData\Local\Programs\Python\Python39\lib\concurrent\futures\_base.py", line 445, in result
    return self.__get_result()
  File "C:\Users\user\AppData\Local\Programs\Python\Python39\lib\concurrent\futures\_base.py", line 390, in __get_result
    raise self._exception
  File "C:\Users\user\AppData\Local\Programs\Python\Python39\lib\concurrent\futures\thread.py", line 52, in run
    result = self.fn(*self.args, **self.kwargs)
  File "C:\Users\user\AppData\Local\Programs\Python\Python39\lib\site-packages\arcgis\_impl\common\_clone.py", line 800, in _clone
    raise ex
  File "C:\Users\user\AppData\Local\Programs\Python\Python39\lib\concurrent\futures\thread.py", line 52, in run
    result = self.fn(*self.args, **self.kwargs)
  File "C:\Users\user\AppData\Local\Programs\Python\Python39\lib\site-packages\arcgis\_impl\common\_clone.py", line 3013, in clone
    raise _ItemCreateException("Failed to create {0} {1}: {2}".format(original_item['type'], original_item['title'], str(ex)), new_item)
arcgis._impl.common._clone._ItemCreateException: ('Failed to create Form IA-OA Sampling Form V2: Failed to update Form IA-OA Sampling Form V2: mismatched tag: line 14, column 61', <Item title:"IA-OA Sampling Form V2" type:Form owner:the_owner_of_portal_account>)

 

0 Kudos
1 Solution

Accepted Solutions
gvanderwaal
New Contributor II

Downgrading to Python 3.6.0 resolved this issue. I attempted this after finding a blog post discussing survey cloning, then finding a related Github page.

View solution in original post

0 Kudos
2 Replies
gvanderwaal
New Contributor II

Does anyone have any pointers in the right direction? This seems like an uncommon error and I haven't seen anyone else encounter it yet.

0 Kudos
gvanderwaal
New Contributor II

Downgrading to Python 3.6.0 resolved this issue. I attempted this after finding a blog post discussing survey cloning, then finding a related Github page.

0 Kudos