Unable to Create Organisation through GroupShare API

I'm building an application which communicates with GroupShare using the REST API, and am encountering an exception when I try to create an organisation.

First of all, we built our own API wrapper to communicate with the GroupShare REST API, and we had this successfully creating orgnisations. For our own reasons we had to create a new VM on which GroupShare is installed, which then required a fresh install of GroupShare on said VM. Since then our API wrapper encounters the aforementioned exception.

I've also tried using Romulus' GroupShareKit, and although both this and our wrapper API can authenticate against the GroupShare server, then query and successfully obtain the root organisation, we still encounter the same exception when sending the request to create a new organisation.

[I should add that I've had to fork and modify GroupShareKit to include an Organziations.Create method - pull request possibly coming soon.]

As per the instructions here, this is the JSON which I'm POSTing to the server:

{
    "UniqueId": "e21c9e02-8b4c-4274-9b9c-8ec76f85863a",
    "Name": "86031",
    "Description": "Test Groupshare Org",
    "Path": "/86031",
    "ParentOrganizationId": "f82b6604-9a9e-47bb-90c1-d907b9db7594",
    "ChildOrganizations": []
}

Other things I've tried:

  • not setting "UniqueId" - if not set then I can see that an empty GUID ("00000000-0000-0000-0000-000000000000") is sent
  • setting "Path" as "/"
  • setting "ChildOrganizations" to NULL

None of the above makes any difference. The response is always:

{
    "Message": "An error has occurred.",
    "ExceptionMessage": "Object reference not set to an instance of an object.",
    "ExceptionType": "System.NullReferenceException",
    "StackTrace": "   at Sdl.StudioServer.Services.Management.RestApi.Controllers.OrganizationsController.AddOrganization(Organization organization)
                    at lambda_method(Closure , Object , Object[] )
                    at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass13.<GetExecutor>b__c(Object instance, Object[] methodParameters)
                    at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.Execute(Object instance, Object[] arguments)
                    at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.<>c__DisplayClass5.<ExecuteAsync>b__4()
                    at System.Threading.Tasks.TaskHelpers.RunSynchronously[TResult](Func`1 func, CancellationToken cancellationToken)"
}


In case it matters, the username and password are those pre-configured for the "sa" user, and no other configuration has taken place on GroupShare other than as required during the installation procedure.

Parents Reply Children
  • I undertook both those steps but the problem remains.

    My log file shows that the new user was authenticated (using GroupShareClient.AuthenticateClient(...) ) and I can see that the new organisation was retrieved (using myGroupShareClient.Organization.GetAll(new OrganizationRequest(true)).Result.LastOrDefault(); - a little dirty, I know, but should suffice for testing) but a call to

    var newOrganization = myGroupShareClient.Organization.Create(newName, order.OrderName, parentOrganization).Result;

    Results in the exception...

    System.AggregateException: One or more errors occurred. ---> Sdl.Community.GroupShareKit.Exceptions.ApiException: An error occurred with this API request
    at Sdl.Community.GroupShareKit.Http.Connection.HandleErrors(IResponse response) in C:\ [...] \groupsharekit.net\Sdl.Community.GroupShareKit\Http\Connection.cs:line 235
    at Sdl.Community.GroupShareKit.Http.Connection.<RunRequest>d__19.MoveNext() in C:\ [...] \groupsharekit.net\Sdl.Community.GroupShareKit\Http\Connection.cs:line 212
  • I see. This error is not very useful and the library might hide a few important details so in order to find a few more details could you please do the following:

    1. Download the GroupShareKit source code from github: .

    2. Build the solution in debug mode on your dev machine .

    3. From your project add reference to the dll produced by your build.

    4. Set a breakpoint on the line where the organization Create method is called and step into the GroupShareKit library.

    5. Step into until you get to this line of code and look at the at the Body property on the response object to see the exception that comes from GroupShare.

    Let me know what exception you get.

    Romulus Crisan | Translation Productivity Development Manager | SDL | (twitter) @cromica_82 | (blog) http://www.romuluscrisan.com/

  • I might be naïve here, but until recently the IOrganizationClient implementation had the return type

    Task<Organization>

    But it now has

    Task<string>

    The comment for this method says <returns>A list of <see cref="Organization"/>s.</returns> but its return type is Task<string>. How do I get the newly-created Organization object back from this method, or is the comment simply wrong?

    UPDATE: The new method does now return a GUID and successfully creates the new organisation.

  • The problem you find is just in the description of the method so nothing changed in the method. Anyway this is a new method which we created last week but the API was always returning just the GUID of the newly created organization (see this page of the documentation ). In order to have the organization object you will need to use GetOrganization method, more about that here:

     

    Can you please let me know what you changed to fix the problem? Also you are now using our latest version from nuget or the one which is custom built by you?

    Romulus Crisan | Translation Productivity Development Manager | SDL | (twitter) @cromica_82 | (blog) http://www.romuluscrisan.com/

  • >> Can you please let me know what you changed to fix the problem?

    I've gradually wound backwards and found that I can now create organisations under the root using the 'sa' login, which I couldn't earlier. Therefore the only change seems to be the GroupShareKit version.
    The only other aspect which has changed is that there is now another organisation and user in the system, though like I said, I'm able to ignore these and achieve what I couldn't before.

    >> Also you are now using our latest version from nuget or the one which is custom built by you?

    I'm using the version which I built on this PC. I'll try the NuGet version right now.


    UPDATE: Yes, it also works with the NuGet package.

  • Great.

    Romulus Crisan | Translation Productivity Development Manager | SDL | (twitter) @cromica_82 | (blog) http://www.romuluscrisan.com/