RESTful knowledge exchange
Post Reply
s.desbois
Novice
Posts: 8
Liked: 1 time
Joined: Aug 10, 2020 3:41 pm
Full Name: Sebastien Desbois
Contact:

Problem creating users in Enterprise Manager with API and JSON

Post by s.desbois »

Hello all,

We are trying to automate the creation of external users on Enterprise Manager (version 10) using API and we have a little problem doing so.
We looked at the docuementation here : https://helpcenter.veeam.com/docs/backu ... ml?ver=100

Problem is that we are doing everything in JSON, not XML.
We tried to build the "EnterpriseAccountCreateSpec" based on what is in the doc but it fails...

Example:

Code: Select all

{
 "EnterpriseAccountCreateSpec": [
  {
   "AccountType": "ExternalUser",
   "AccountName": "bidochon@wtf.fr",
   "Roles": {
    "EnterpriseRole": [
     {
      "EnterpriseRoleUid": "urn:veeam:EnterpriseRole:f84a8b62-49b8-4d0c-b25b-92321b52bab6"
     }
    ]
   },
   "HierarchyScopeObjects": [
    {
     "HierarchyScopeItem": {
      "HierarchyObjRef": "urn:VMware:Tag:23ce9e0f-07b3-4c75-bb80-6fb9ad7a6b59.urn:vmomi:InventoryServiceTag:c64fd257-8244-42d1-a158-38a3a7439fe9:GLOBAL"
     }
    },
    {
     "HierarchyScopeItem": {
      "HierarchyObjRef": "urn:VMware:Tag:e5dac1d0-9491-4200-acc3-6c320ce2d971.urn:vmomi:InventoryServiceTag:c64fd257-8244-42d1-a158-38a3a7439fe9:GLOBAL"
     }
    }
   ],
   "FlrSettings": {
    "FlrInplaceOnly": false
   },
   "SqlSettings": {
    "DenyInPlaceRestore": false
   }
  }
 ]
}
And what we get in Svc.VeeamRestAPI.log is that
[10.08.2020 17:27:54] <55> Info [POST] request to [https://XX.XX.XX.XX:9398/api/security/accounts] deserialized. Message: [{"EnterpriseAccountCreateSpec": [{"AccountType": "ExternalUser", "AccountName": "bidochon@wtf.fr", "Roles": {"EnterpriseRole": [{"EnterpriseRoleUid": "urn:veeam:EnterpriseRole:f84a8b62-49b8-4d0c-b25b-92321b52bab6"}]}, "HierarchyScopeObjects": [{"HierarchyScopeItem": {"HierarchyObjRef": "urn:VMware:Tag:23ce9e0f-07b3-4c75-bb80-6fb9ad7a6b59.urn:vmomi:InventoryServiceTag:c64fd257-8244-42d1-a158-38a3a7439fe9:GLOBAL"}}, {"HierarchyScopeItem": {"HierarchyObjRef": "urn:VMware:Tag:e5dac1d0-9491-4200-acc3-6c320ce2d971.urn:vmomi:InventoryServiceTag:c64fd257-8244-42d1-a158-38a3a7439fe9:GLOBAL"}}], "FlrSettings": {"FlrInplaceOnly": false}, "SqlSettings": {"DenyInPlaceRestore": false}}]}]; Parameters: [].
[10.08.2020 17:27:54] <65> Error Failed add account.. RequestUri: [URI template match was not found].
[10.08.2020 17:27:54] <65> Error The specified account type is invalid: (Veeam.Backup.Interaction.RestAPI.CRestAPICommunicationException)
[10.08.2020 17:27:54] <65> Error at Veeam.Backup.Enterprise.RestAPIService.CRestApiSecurityScope.AddAccount(EnterpriseAccountCreateSpecType spec)
[10.08.2020 17:27:54] <65> Error at Veeam.Backup.Enterprise.RestAPIService.CRestSecurityControllerStub.<AddAccount>d__7.MoveNext()
Are we missing something or something else?

Thank you.

(Having an official documentation in json could help ^^)
Natalia Lupacheva
Veteran
Posts: 1143
Liked: 302 times
Joined: Apr 27, 2020 12:46 pm
Full Name: Natalia Lupacheva
Contact:

Re: Problem creating users in Enterprise Manager with API and JSON

Post by Natalia Lupacheva »

Hi Sebastien,

you don't need root element here, so you can try the following version:

Code: Select all

{
  "AccountType": "ExternalUser",
  "AccountName": "external@google.com",
  "Roles": {
    "EnterpriseRoles": [
      {
        "EnterpriseRoleUid": "urn:veeam:EnterpriseRole:f83e4c81-0815-452f-9377-9d573dd9d481"
      }
    ]
  },
  "AllowRestoreAllVms": true,
  "FlrSettings": {
    "FlrInplaceOnly": false,
    "FlrExtentionRestrictions": "png, pdf"
  },
  "SqlSettings": {
    "DenyInPlaceRestore": true
  }
}
Also, cannot provide any ETA now, but we are already working on examples in JSON.
Thanks!
s.desbois
Novice
Posts: 8
Liked: 1 time
Joined: Aug 10, 2020 3:41 pm
Full Name: Sebastien Desbois
Contact:

Re: Problem creating users in Enterprise Manager with API and JSON

Post by s.desbois »

Thanks for the answer.
Removing the root helped, but still stuck...

I tried without "HierarchyScopeObjects" and with it, I tried to change the "EnterpriseRoleUid", without success...

Code: Select all

{
 "AccountType": "ExternalUser",
 "AccountName": "bidochon@wtf.fr",
 "AllowRestoreAllVms": false,
 "Roles": {
  "EnterpriseRole": {
   "EnterpriseRoleUid": "urn:veeam:EnterpriseRole:f84a8b62-49b8-4d0c-b25b-92321b52bab6"
  }
 },
 "FlrSettings": {
  "FlrInplaceOnly": false
 },
 "SqlSettings": {
  "DenyInPlaceRestore": false
 },
 "HierarchyScopeObjects": {
  "HierarchyScopeItem": {
   "HierarchyObjRef": "urn:VMware:Tag:23ce9e0f-07b3-4c75-bb80-6fb9ad7a6b59.urn:vmomi:InventoryServiceTag:c64fd257-8244-42d1-a158-38a3a7439fe9:GLOBAL",
   "ObjectName": "RD"
  }
 }
}
[11.08.2020 13:35:07] <20> Info [POST] request to [https://10.246.14.224:9398/api/security/accounts] deserialized. Message: [{"AccountType": "ExternalUser", "AccountName": "bidochon@wtf.fr", "AllowRestoreAllVms": false, "Roles": {"EnterpriseRole": {"EnterpriseRoleUid": "urn:veeam:EnterpriseRole:d19a3d33-cb77-4ffe-94e6-001432483a4e"}}, "FlrSettings": {"FlrInplaceOnly": false}, "SqlSettings": {"DenyInPlaceRestore": false}, "HierarchyScopeObjects": {"HierarchyScopeItem": {"HierarchyObjRef": "urn:VMware:Tag:23ce9e0f-07b3-4c75-bb80-6fb9ad7a6b59.urn:vmomi:InventoryServiceTag:c64fd257-8244-42d1-a158-38a3a7439fe9:GLOBAL", "ObjectName": "RD"}}}]; Parameters: [].
[11.08.2020 13:35:07] <08> Info Sql query: [SELECT COUNT(id) as RowsCount FROM [dbo].[Rest.AccountsView] q1 WHERE (q1.[name]=@Name0 AND q1.[type]=@AccountType1)], args: [@Name0 = bidochon@wtf.fr, @AccountType1 = 3]
[11.08.2020 13:35:07] <08> Info Sql query: [SELECT *, ROW_NUMBER() OVER (ORDER BY id) as RowNumber FROM [dbo].[Rest.AccountsView] q1 WHERE (q1.[name]=@Name0 AND q1.[type]=@AccountType1)], args: [@Name0 = bidochon@wtf.fr, @AccountType1 = 3]
[11.08.2020 13:35:07] <08> Error Failed add account.. RequestUri: [URI template match was not found].
[11.08.2020 13:35:07] <08> Error Object reference not set to an instance of an object. (System.NullReferenceException)
[11.08.2020 13:35:07] <08> Error at Veeam.Backup.Enterprise.RestAPIService.CRestApiSecurityScope.AddAccount(EnterpriseAccountCreateSpecType spec)
[11.08.2020 13:35:07] <08> Error at Veeam.Backup.Enterprise.RestAPIService.CRestSecurityControllerStub.<AddAccount>d__7.MoveNext()
But there is definitively some progress :)
Natalia Lupacheva
Veteran
Posts: 1143
Liked: 302 times
Joined: Apr 27, 2020 12:46 pm
Full Name: Natalia Lupacheva
Contact:

Re: Problem creating users in Enterprise Manager with API and JSON

Post by Natalia Lupacheva » 2 people like this post

Sebastien,

let's fix the following:
EnterpriseRole -> EnterpriseRoles (it should be an array, not a single object);
HierarchyScopeItem -> HierarchyScopeItems (also an array):

Code: Select all

{
  "AccountType": "ExternalUser",
  "AccountName": "external@google.com",
  "Roles": {
    "EnterpriseRoles": [
      {
        "EnterpriseRoleUid": "urn:veeam:EnterpriseRole:d19a3d33-cb77-4ffe-94e6-001432483a4e"
      }
    ]
  },
  "AllowRestoreAllVms": false,
  "HierarchyScopeObjects": {
    "HierarchyScopeItems": [
      {
        "HierarchyObjRef": "urn:VMware:Vm:2ac782db-d254-472b-99ce-b523174dde75.vm-584",
        "ObjectName": "vm-manager"
      }
    ]
  },
  "FlrSettings": {
    "FlrInplaceOnly": false,
    "FlrExtentionRestrictions": "png, pdf"
  },
  "SqlSettings": {
    "DenyInPlaceRestore": true
  }
}
Thanks!
s.desbois
Novice
Posts: 8
Liked: 1 time
Joined: Aug 10, 2020 3:41 pm
Full Name: Sebastien Desbois
Contact:

Re: Problem creating users in Enterprise Manager with API and JSON

Post by s.desbois » 1 person likes this post

Thank you very much, this is working perfectly!

The s in EnterpriseRoles and HierarchyScopeItems were tricky to find. (No s in the xml version)

Thanks again :)
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest