I am working on a script that pulls in building footprints from Open Street Maps footprints from the ESRI hosted OSM layer. I am able to make the request fine and get the JSON output. Then I am using arcpy.conversion.JSONToFeatures to output the results to a layer. JSONToFeatures fails with a parsing error when I use the following code below. However once I have the file written I tried running the JSONToFeatures in ArcGIS Pro manually and it works just fine. So then I commented out the write to file section of my code and used the preciously saved text file and it works fine.
So why is it when I am writing the file then using JSONToFeatures write after it is not able to parse the file? I have tired closing the file before calling JSONToFeatures to see if that helps but it doesn't.
osmFootprint = os.path.join(scratch, 'OSMBuildingFootprint')
fp = os.path.join(scratchFolder, 'temp.json')
f = open(fp,"w")