Hello I have the following html script where I am able to successfully generate a token, and upload a csv to my organization's Arcgis online platform. The csv contains some fields, latitude, and longitude. Clicking the publish function on the layer manually works to create a feature layer (hosted) containing a point layer from the provided latitude and longitude in the CSV.
However when I try to incorporate this function in my html script I get the following type of errors:
Error publishing CSV: Unexpected token '<', "<!DOCTYPE "... is not valid JSON
Error: Unable to parse the response as JSON.
I also tried to add item type as Feature Collection instead of csv to bypass the publish portion of the script but it said I did not have permission... (when I was able to do the same action but with item type as CSV)
Appreciate any help on this
html code: https://jsfiddle.net/hjmazn0x/
Doing this in python is not an option for me.