I was trying to download a hosted feature layer by using the ArcGIS Python API.
The workflow I followed is to export the layer as a file geodatabase first, then search for its itemID by using 'content.search()' and finally using the 'get_data()' to download the FGB to the temp file path.
However, the problem is that the script is not stable (I think it may be a bug) because with the exact code, sometime it would download the exported FGB with only 1 KB in size, while the rest of time it would download FGB with the correct size. I cannot find the problem because everything seems work perfectly when I test the code out in Jupyter Notebook, until the very last step where I try to download the exported FGB.
Any help would be appreciated!
The followings are a subset of my script:
fgb_item_id = search_fgb.id