Here is a JavaScript $ dojo sample I created which uploads a json file. It is small json file created dynamically on the client side. You would send your token in the content object if you had one.
var myJson = JSON.stringify(this._serializeGraphics({myProp: myVal}));
var blob = new Blob([myJson], { type: "application/json" });
var formNode = put("form", {
"method": "post",
"enctype": "multipart/form-data"
});
var formData = new FormData(formNode);
formData.append("itemType", "file");
formData.append("type", "GeoJson");
formData.append("title", this.title);
formData.append("file", blob, this.filename);
var path = "content/users/" + this.portalUser.username + '/' + folder + "/addItem";
return esriRequest({
url: this.portal.portalUrl + path,
form: formData,
content: {
f: "json"
}
}, { usePost: true }).then(this._saveSuccessful, this._error);
Aangemelde leden kunnen berichten plaatsen, updates volgen en meer. Nieuw hier? Registreer een gratis account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.