Select to view content in your preferred language

JavaScript API esriRequest applyEdits to portal feature table

954
1
09-19-2017 08:50 AM
ShirleyLi
Occasional Contributor

I'm sending an esriRequest to a feature table hosted on our portal to add new features via POST method

I use "esriConfig.request.maxUrlLength = 1; " which forces the request to use POST.  now the request goes through but nothing is posted...

esriConfig.portalUrl = "<portalURL>";

esriConfig.request.maxUrlLength = 1;

setTimeout(function(){
on(dom.byId("submitrecord"), "click", function(){
esriRequest('<featuretableURL>/applyEdits',{
query: {
method: 'POST',
adds: [
{
"attributes": {
"Notes": "code test",
"roomID": 1234
}
}
],
f:"json"
},
}).then(function(r){
console.log(r);
});


});
},5000);

I'm using JavaScript api 4.4. and applyedits for feature layer seems not working for tables. so I'm using the esriRequest

I also tried to directly send the request in the browser at '<featuretableURL>/applyEdits'. I copied the request body

[
{
"attributes": {
"Notes": "code test",
"roomID": 1234
}
}
]

to the "adds" box and it successfully added the feature. 

Any help is appreciated!

0 Kudos
1 Reply
deleted-user-01arXz5EpgFA
Deactivated User

I'm doing something similar because I'm working with 'flat' tables and not 'feature layers' as well.  I also ran into an issue like this but eventually resolved it (after making sure it was using POST) by using JSON.stringify() on my data.  An example using your code would be something like:

...

adds: JSON.stringify([{ attributes: { "Notes": "code test", "roomID": 1234 }}]),

...

I'm not sure if this will help you but might be worth a try.  And I did get the esriRequest('<featuretableURL>/applyEdits'... call working for all adds, updates and deletes on tables.  

Good luck!