Hi Nick,
Thank you for your prompt reply, it was much appreciated.
I have investigated the user’s permissions as you requested but this really does not seem to be the cause of the problem. Here is why:
These are the permissions that I have granted to the user.
I first performed a test to make sure that I was working with the correct User Role. When I REVOKE the TenantCreate permission, then I am unable to create a new Tenant through the API. However, I get a very different error to the one that I put in my original post:
“You do not have permission to perform this action. Please contact your Octopus administrator. Missing permission: TenantCreate”
I then restored the TenantCreate permission and revoked the TenantView permission. I get the following error when my code then attempts to modify the Tenant. The errors is once again on the call to octopusAsyncRepository.Tenants.CreateOrModify(tenantName):
You do not have permission to perform this action. Please contact your Octopus administrator. Missing permission: TenantView
Source: Octopus.Client
Stack Trace:
at Octopus.Client.OctopusAsyncClient.<DispatchRequest>d__54`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Octopus.Client.OctopusAsyncClient.<Get>d__33`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Octopus.Client.OctopusAsyncClient.<List>d__38`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Octopus.Client.OctopusAsyncClient.<Paginate>d__40`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Octopus.Client.Repositories.Async.BasicRepository`1.<FindOne>d__9.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Octopus.Client.Editors.Async.TenantEditor.<CreateOrModify>d__9.MoveNext()
In other words I am unable to replicate what your results; I do not get my original error (" - A tenant with this name already exists. Please choose a different name.") by revoking TenantView.
As I final test I restored the TenantView permission. I got back my original error again.
You also said that the exact casing of the name of the Tenant might be the cause. I am uncertain how this could be a factor; the phrase “this name already exists” in the error implies that the names match as expected. If I had the wrong case, then I would expect to to create a new Tenant.
For the record, here is the name:
[DEV][Test Org 2][FFFFFFFF7BA543CF8A6572BB0F7A43C0]
Have you got any other suggestions for what could be preventing the Octopus.Client from modifying an existing Tenant?
Thanks,
Keith