Hi all,
I am struggling to create a folder with javascript 4.14 calling esriRequest
Here is an example function I am trying to get working... (myuser is just for example purposes)
function createProjectFolder(folderName){
var url = "https://www.arcgis.com/sharing/rest/content/users/myuser/createFolder";
var folderParams = {
title: folderName
};
var headers = {
"Access-Control-Allow-Origin": "*",
"content-type": "multipart/form-data",
"accept": "application/json"
};
esriRequest(url, {
method: "post",
headers: headers,
content: folderParams,
responseType: "json",
}).then(function (response) {
console.log(response);
});
};
I keep getting a these CORS errors
OPTIONS https://www.arcgis.com/sharing/rest/content/users/myuser/createFolder 405
(anonymous) @ dojo.js:695
e @ dojo.js:428
(anonymous) @ dojo.js:427
(anonymous) @ dojo.js:622
k @ dojo.js:431
(anonymous) @ dojo.js:622
D @ dojo.js:691
(anonymous) @ dojo.js:700
e @ dojo.js:428
(anonymous) @ dojo.js:427
n @ dojo.js:622
d @ dojo.js:136
then.a.then @ dojo.js:139
p @ dojo.js:622
(anonymous) @ dojo.js:622
k @ dojo.js:431
(anonymous) @ dojo.js:622
I @ dojo.js:700
(anonymous) @ dojo.js:684
e @ dojo.js:428
(anonymous) @ dojo.js:427
n @ dojo.js:622
d @ dojo.js:136
then.a.then @ dojo.js:139
p @ dojo.js:622
(anonymous) @ dojo.js:622
k @ dojo.js:431
(anonymous) @ dojo.js:622
t @ dojo.js:682
(anonymous) @ dojo.js:682
k @ dojo.js:431
r @ dojo.js:682
createProjectFolder @ main.js:89
(anonymous) @ main.js:74
Show 4 more frames
/ago/#:1 Access to fetch at 'https://www.arcgis.com/sharing/rest/content/users/myuser/createFolder' from origin 'https://localhost' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: It does not have HTTP ok status.
Can anyone shed some light on what I have to do to get this to work?
request | ArcGIS API for JavaScript 4.14
Create Folder—ArcGIS REST API: Users, groups, and content | ArcGIS for Developers