I would like to add records to a table using REST API. I followed Robert Scheitlin, GISP's example to retrieve a table here, and modified the URL with the following one:
"http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/SanFrancisco/311Incidents/FeatureServer/1/addFeatures?features=[{'attributes' : {'agree_with_incident' : '2', 'notes' : 'my notes..'}}]&f=json";
based on Domenico Ciavarella's answer in this post. However, I am getting this error in the console when I try to execute the request: "dojo.io.script error Error: Unable to complete operation."
I am very new to the REST API, and I don't see many examples. Here is my entire code
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no">
<title>Add a Record</title>
<style>
td {
padding: 4px;
}
#loading {
visibility: hidden;
}
</style>
<script src="http://js.arcgis.com/4.2/"></script>
<script>
require([
"esri/request",
"esri/config",
"dojo/json",
"dojo/dom",
"dojo/on",
"dojo/domReady!"
], function(esriRequest, esriConfig, JSON, dom, on) {
esriConfig.request.proxyUrl = "http://gislap183/js/proxy/proxy.ashx";
function doRequest(){
var url = "http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/SanFrancisco/311Incidents/FeatureServer/1...[{'attributes' : {'agree_with_incident' : '2', 'notes' : 'my notes..'}}]&f=json";
esriRequest(url, {
responseType: "json",
callbackParamName: "callback"
}).then(function(response){
showResults(response);
});
}
var resultsTable = dom.byId("tbl");
function showResults(response) {
var results = response.data;
resultsTable.innerHTML = JSON.stringify(results);
}
function rejectedPromise(err) {
console.error("Promise didn't resolve: ", err.message);
}
on(dom.byId("execBtn"), "click", doRequest);
});
</script>
</head>
<body>
<input type="button" value="Execute" id="execBtn" />
<br>
<br>
<table id="tbl"></table>
</body>
</html>
How can I fix this? Thanks.