[GIS] Adding feature layer to ArcGIS Online from REST API

arcgis-javascript-apiarcgis-onlinearcgis-rest-api

I need to add a feature layer to ArcGIS Online account from code.

i have created a developer account where if i want to create a feature layer i have to upload a CSV file and it makes the feature layer.

Problem is: i need to create the sane feature layer using my code.
like is there any REST API or some API which ArcGIS provide this
option?

Best Answer

I've checked requests which were sent in ArcGIS Online to add Feature Service with Chrome dev tools and found that it uses 4 requests:

  1. Create Service - create feature service with REST API without layers, see http://resources.arcgis.com/en/help/arcgis-rest-api/#/Create_Service/02r30000027r000000/
  2. update Service item - fix service name, see http://resources.arcgis.com/en/help/arcgis-rest-api/#/Update_Item/02r30000009s000000/
  3. addToDefinition request for admin part, see http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#/Add_To_Definition_Feature_Service/02r300000230000000/ - this is the request to add layer definition into empty service
  4. Last request to updateDefinition of the service (http://resources.arcgis.com/en/help/arcgis-rest-api/#/Update_Definition_Feature_Service/02r30000021z000000/).
Related Question