koltyakov / gosip

⚡️ SharePoint SDK for Go
https://go.spflow.com
MIT License
140 stars 32 forks source link

Not all role definitions are supported by 'GetByName' function #27

Closed swapnilgaonkar closed 4 years ago

swapnilgaonkar commented 4 years ago

Function sp.Web().RoleDefinitions().GetByName() is working fine for (edit, read, Design) but it is not working for (Manage Hierarchy, Restricted Read, Restricted Interfaces for Translation). It fails with error 'value does not fall within the expected range'

Can you provide any help

koltyakov commented 4 years ago

Hi @swapnilgaonkar,

You can try getting all roles and check which exist. For none existing role definitions it's expected to receive an error from the API.

rd, err := web.RoleDefinitions().Get()
if err != nil {
  t.Error(err)
}
for _, r := range rd {
  fmt.Println(r.Name)
}
swapnilgaonkar commented 4 years ago

Thanks for the reply and sorry for the delayed response. It was issue from my side. Above functionality working as expected. Thanks

koltyakov commented 4 years ago

Thanks for coming back with the update. Closing the issue.