Set sharing level for an item

Learn how to use the portal service to set the sharing level for an item in your portal.

Prerequisites

You need an ArcGIS Location Platform, ArcGIS Online, or ArcGIS Enterprise account to use your portal.

Steps

Get an access token

To perform the portal service operation in this tutorial, you need an access token from OAuth 2.0 credentials. It is the only supported form of authentication. The use of API keys is not supported.

  1. Go to the Create OAuth credentials for user authentication tutorial to get a set of OAuth 2.0 credentials.

  2. Get an access token from the OAuth 2.0 credentials.

  3. Copy the access token to your clipboard when prompted.

Set up environment

  1. In a different window, launch Postman and create a blank request.

Create a new private item

You will create a new web map in your portal. The default sharing level will be private. In a later step, you will use the web map item ID to change the sharing level to public using the portal service.

  1. In a different tab, sign in to your portal.
  2. Click on Map to open up Map Viewer.
  3. Add a basemap, layer, and viewpoint for your map.
  4. Click Save > Save as.
  5. Provide a title and tags for your web map. Then, click Save.
  6. In the URL part of your browser, copy the web map item ID and store it in a safe location. You can find the item ID in https://arcgis.com/apps/mapviewer/index.html?webmap=<ITEM_ID>. You will use this item ID in a later step.

Perform a share request

Now, you will be changing the sharing level of your item from private to public using the portal service.

  1. Set the request type to POST.
  2. In the URL field, type in https://arcgis.com/sharing/rest/content/users/<USER_NAME>/items/<ITEM_ID>/share. Replace <USER_NAME> with your username and <ITEM_ID> with the item ID you copied in the previous step.
  3. Set the f parameter to pjson in the parameter list.
  4. Set the everyone parameter to true to set the sharing level to public. To see other sharing levels, go to Sharing items.
  5. Set the token parameter to your access token.
  6. Set the q parameter to type: "Web Map" in the parameter list.
  7. Run the request.
HTTPHTTPcURL
Use dark colors for code blocksCopy
1
2
3
4
5
6
POST https://arcgis.com/sharing/rest/content/users/<USER_NAME>/items/<ITEM_ID>/share
Content-Type: application/x-www-form-urlencoded

&f=json
&everyone=true
&token=<YOUR_ACCESS_TOKEN>

View the results

Go back to your portal and you should see that the sharing level of your item has changed to public. Your code may also print an output like this to verify that the operation was successful:

Use dark colors for code blocksCopy
1
2
3
4
{
    "notSharedWith": [],
    "itemId": "<ITEM_ID>"
}

What's next

Copy a hosted layer item

Use the portal service to copy a hosted layer item in your portal.


Create a new group and add members

Use the portal service to create a new group and add members in your portal.


Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.