Skip to content

Instantly share code, notes, and snippets.

@tomwayson
Created July 10, 2013 18:03
Show Gist options
  • Save tomwayson/5968622 to your computer and use it in GitHub Desktop.
Save tomwayson/5968622 to your computer and use it in GitHub Desktop.
An AMD utility module for working with ArcGIS portal items that including helper functions missing from other esri/arcgis classes (addItem, etc)
define([
"dojo/io-query",
"esri/request",
"esri/arcgis/utils"
],
function(
ioQuery,
esriRequest,
arcgisUtils
) {
return {
// add an item to a portal users's content
// assumes portal user is already logged in (using identity manager)
addItem: function (portalUser, content) {
var requestParams = { f: "json", token: portalUser.credential.token };
var url = portalUser.portal.portalUrl + "content/users/" + portalUser.username + "/addItem";
url += "?" + ioQuery.objectToQuery(requestParams);
return esriRequest({
url: url,
content: content
}, {
usePost: true
});
},
// get item info and item data
// wraps arcgisUtils.getItem function to
// make it more generic for other portals
getItem: function(portal, itemId) {
arcgisUtils.arcgisUrl = portal.url + "/sharing/content/items";
return arcgisUtils.getItem(itemId);
}
};
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment