Esri / arcgis-rest-js

compact, modular JavaScript wrappers for the ArcGIS REST API
https://developers.arcgis.com/arcgis-rest-js/
Apache License 2.0
353 stars 121 forks source link

Elevating User Level #713

Open FardoshtAmirpanahi opened 4 years ago

FardoshtAmirpanahi commented 4 years ago

I am trying to elevate a user level from "1" to "2". The following Update method returns successfully, but the user level stays at "1". updateUser({authentication: this.adminSession, user:{username:this.member.username, level: "2" }}).then(response => { alert("Update Successful"); }).catch(error => { alert(error); }) Best regards, Fardosht

FardoshtAmirpanahi commented 4 years ago

Both under ArcGIS API for Python and REST API there is a separate method to update user level. I couldn't find a similar method under ArcGIS REST JS.

I very much appreciate it if someone could suggest a workaround. I have spent a lot of time on this dashboard to have to abandon it for this one functionality.

https://developers.arcgis.com/python/api-reference/arcgis.gis.toc.html#user https://developers.arcgis.com/rest/users-groups-and-items/update-user-level.htm

Best Regards, Fardosht

FardoshtAmirpanahi commented 4 years ago

Can anyone help me with this?

jgravois commented 4 years ago

have you tried passing that value as an integer instead of a string?

updateUser({
  authentication: this.adminSession, 
  user: { 
    username:this.member.username, 
    level: 2 
  }
})

if that doesn't work i don't have a better idea than sniffing the web traffic in ArcGIS Online and seeing if you can spot the difference in the request there.

FardoshtAmirpanahi commented 4 years ago

Thanks jgravois for your sugession. I have almost exact the same code. Even thought the alert shows response was successful, the user's level does not change.

I checked the this.member.level is 2. I even tried "2".

updateUser({ authentication: this.adminSession, user:{ username:this.member.username, level: this.member.level } }).then(response => { alert(response.success) }).catch(error => { alert(error); })

All the best, Fardosht