I am trying to add a feature to a service layer using ajax post. I get a 200 back but when i query the service, the post feature does not show. I am using ArcGis Online 1.5.1
service:
Solved! Go to Solution.
I finally fixed it, for some reason it wanted me to post my data as a string in the url, instead of withing my request body. Here is the code for anyone that wants to try this:
const url = 'https://services2.arcgis.com/qvkbeam7Wirps6zC/ArcGIS/rest/services/service_e85611f4185545fab4a50ca81... encodeURIComponent(JSON.stringify(data)) +'&f=json';
var request = new Request(url, {
method: 'POST',
body: '',
headers: new Headers()
});
fetch(request)
.then((resp) => {
console.log(resp);
console.log(resp.status);
if(resp.status === 200){
console.log('item submitted');
}
});
Edgar,
Can you elaborate as to why you are attempting to add the feature using AJAX instead of the FeatureLayer.applyEdits([new features]) method?
I have light a custom application with a form that post to our service. Do I need arcgis.js to do any edits to services?
No it should not be necessary. can you post the code you are using for the AJAX Post?
I finally fixed it, for some reason it wanted me to post my data as a string in the url, instead of withing my request body. Here is the code for anyone that wants to try this:
const url = 'https://services2.arcgis.com/qvkbeam7Wirps6zC/ArcGIS/rest/services/service_e85611f4185545fab4a50ca81... encodeURIComponent(JSON.stringify(data)) +'&f=json';
var request = new Request(url, {
method: 'POST',
body: '',
headers: new Headers()
});
fetch(request)
.then((resp) => {
console.log(resp);
console.log(resp.status);
if(resp.status === 200){
console.log('item submitted');
}
});