Select to view content in your preferred language

Administrator token doesn't have permission to access operation

132
1
12-03-2024 02:53 PM
Labels (1)
FrancisYang1
New Contributor

I have a function as follows:

export const addGeoJsonItem = async (
  token: string,
  username: string,
  url: string,
  teamId: number,
  countyName: string,
  folderId: string | null = null
) => {
  const addItemUrl = `https://www.arcgis.com/sharing/rest/content/users/${username}/addItem`;
  const geoJsonUrl = `${url}${teamId}`;
  const addItemParams = new URLSearchParams({
    f: 'json',
    token,
    type: 'GeoJson',
    url: geoJsonUrl,
    title: `${countyName}_all_points`,
  });

  if (folderId) {
    addItemParams.append('folder', folderId);
  }

  const response = await axios.post(addItemUrl, addItemParams, {
 
  });

  if (response.data.error) {
    throw new Error(response.data.error.message);
  }

  return response.data;
};

However, I get an issue saying Error: You do not have permissions to access this resource or perform this operation. I know that the token is valid from testing other endpoints as well as all of the other variables so this must be kind of permissions issue with my account settings, but I can't find anything that might be the culprit. My account is an administrator and I haven't touched the settings at all so I'm not sure what the problem could be.
0 Kudos
1 Reply
ChristopherCounsell
MVP Regular Contributor

https://developers.arcgis.com/rest/users-groups-and-items/add-item/#description

This operation is available only to the specified user.

I can't see anything to support that you can call this for other user accounts?

Going to the ArcGIS Online > Organization > Members > Manager Member's items, I don' that the UI to add items on behalf of that user. The response you see also indicates it's not possible.

Can you change the workflow to add the item to your user account and then change ownership?

0 Kudos