diff --git a/datastore_server/source/java/ch/ethz/sis/openbis/generic/server/dssapi/v3/DataStoreServerApi.java b/datastore_server/source/java/ch/ethz/sis/openbis/generic/server/dssapi/v3/DataStoreServerApi.java
index 57ddb1b8f21d0715a2a89227708174ff4a51c6cf..f1d90764103faf759231e58d54f671df1380b6b6 100644
--- a/datastore_server/source/java/ch/ethz/sis/openbis/generic/server/dssapi/v3/DataStoreServerApi.java
+++ b/datastore_server/source/java/ch/ethz/sis/openbis/generic/server/dssapi/v3/DataStoreServerApi.java
@@ -49,9 +49,11 @@ import ch.ethz.sis.openbis.generic.asapi.v3.dto.dataset.id.DataSetPermId;
 import ch.ethz.sis.openbis.generic.asapi.v3.dto.dataset.search.DataSetSearchCriteria;
 import ch.ethz.sis.openbis.generic.asapi.v3.dto.datastore.id.DataStorePermId;
 import ch.ethz.sis.openbis.generic.asapi.v3.dto.datastore.id.IDataStoreId;
+import ch.ethz.sis.openbis.generic.asapi.v3.dto.entitytype.id.EntityTypePermId;
 import ch.ethz.sis.openbis.generic.asapi.v3.dto.entitytype.id.IEntityTypeId;
 import ch.ethz.sis.openbis.generic.asapi.v3.dto.experiment.id.IExperimentId;
 import ch.ethz.sis.openbis.generic.asapi.v3.dto.sample.id.ISampleId;
+import ch.ethz.sis.openbis.generic.asapi.v3.exceptions.UnsupportedObjectIdException;
 import ch.ethz.sis.openbis.generic.dssapi.v3.IDataStoreServerApi;
 import ch.ethz.sis.openbis.generic.dssapi.v3.dto.dataset.create.FullDataSetCreation;
 import ch.ethz.sis.openbis.generic.dssapi.v3.dto.datasetfile.DataSetFile;
@@ -92,6 +94,7 @@ import ch.systemsx.cisd.openbis.dss.generic.shared.utils.PathInfoDataSourceProvi
 import ch.systemsx.cisd.openbis.generic.server.authorization.annotation.RolesAllowed;
 import ch.systemsx.cisd.openbis.generic.shared.basic.dto.RoleWithHierarchy;
 import ch.systemsx.cisd.openbis.plugin.query.shared.api.v1.IQueryApiServer;
+
 import net.lemnik.eodsql.QueryTool;
 
 /**
@@ -356,31 +359,44 @@ public class DataStoreServerApi extends AbstractDssServiceRpc<IDataStoreServerAp
             ownerType = DataSetOwnerType.EXPERIMENT;
             owner = new NewDataSetDTO.DataSetOwner(ownerType, experimentIdentifier.toString());
         }
-        if(owner == null) {
+        if (owner == null)
+        {
             throw new UserFailureException("A dataset needs either a Sample or Experiment as owner.");
         }
         IEntityTypeId typeId = dataSetCreation.getMetadataCreation().getTypeId();
-        
+        String typeCode = null;
+
+        if (typeId != null)
+        {
+            if (typeId instanceof EntityTypePermId)
+            {
+                typeCode = ((EntityTypePermId) typeId).getPermId();
+            } else
+            {
+                throw new UnsupportedObjectIdException(typeId);
+            }
+        }
+
         List<FileInfoDssDTO> fileInfos = FileInfoDssBuilder.getFileInfos(temporaryIncomingDir);
 
-        NewDataSetDTO dataSet = new NewDataSetDTO(typeId.toString(), owner, null, fileInfos);
+        NewDataSetDTO dataSet = new NewDataSetDTO(typeCode, owner, null, fileInfos);
         return dataSet;
     }
-    
+
     private List<FullDataSetCreation> filterPhysicalDataSets(List<FullDataSetCreation> newDataSets)
     {
         return newDataSets
-        .stream()
-        .filter((dataSetCreation) -> dataSetCreation.getMetadataCreation().getPhysicalData() != null)
-        .collect(Collectors.toList());
+                .stream()
+                .filter((dataSetCreation) -> dataSetCreation.getMetadataCreation().getPhysicalData() != null)
+                .collect(Collectors.toList());
     }
 
     private List<FullDataSetCreation> filterNonPhysicalDataSets(List<FullDataSetCreation> newDataSets)
     {
         return newDataSets
-        .stream()
-        .filter((dataSetCreation) -> dataSetCreation.getMetadataCreation().getPhysicalData() == null)
-        .collect(Collectors.toList());
+                .stream()
+                .filter((dataSetCreation) -> dataSetCreation.getMetadataCreation().getPhysicalData() == null)
+                .collect(Collectors.toList());
     }
 
     @Override
@@ -442,29 +458,37 @@ public class DataStoreServerApi extends AbstractDssServiceRpc<IDataStoreServerAp
         for (FullDataSetCreation dataSetCreation : newDataSets)
         {
             PutDataSetService putService =
-                    new PutDataSetService(ServiceProvider.getOpenBISService(), operationLog);   
+                    new PutDataSetService(ServiceProvider.getOpenBISService(), operationLog);
             putService.setStoreDirectory(ServiceProvider.getConfigProvider().getStoreRoot());
             NewDataSetDTO newDataset;
             try
-            {   DataSetCreation metadataCreation = dataSetCreation.getMetadataCreation();
+            {
+                DataSetCreation metadataCreation = dataSetCreation.getMetadataCreation();
                 CreationId creationId = metadataCreation.getCreationId();
                 String dataSetTypeCodeNull = null;
                 IEntityTypeId typeId = metadataCreation.getTypeId();
-                if(null != typeId) {
-                    dataSetTypeCodeNull = typeId.toString(); 
+                if (null != typeId)
+                {
+                    if (typeId instanceof EntityTypePermId)
+                    {
+                        dataSetTypeCodeNull = ((EntityTypePermId) typeId).getPermId();
+                    } else
+                    {
+                        throw new UnsupportedObjectIdException(typeId);
+                    }
                 }
-                File temporaryIncomingDir =  putService.getTemporaryIncomingDir(dataSetTypeCodeNull, creationId.toString());
+                File temporaryIncomingDir = putService.getTemporaryIncomingDir(dataSetTypeCodeNull, creationId.toString());
                 newDataset = getNewDataSet(dataSetCreation, temporaryIncomingDir);
                 String code = dataSetCreation.getMetadataCreation().getCode();
                 putService.putDataSet(sessionToken, newDataset, creationId.toString(), code);
-                
+
             } catch (IOException e)
             {
                 operationLog.error(e.getMessage());
             }
         }
     }
-    
+
     private void injectDataStoreIdAndCodesIfNeeded(List<FullDataSetCreation> newDataSets)
     {
         String dataStoreCode = configProvider.getDataStoreCode();
diff --git a/openbis/source/sql/postgresql/166/grants-166.sql b/openbis/source/sql/postgresql/166/grants-166.sql
index 7d3b24b7bc5294f7f68c3e320b4afad4f4bf85ea..8d81b1f5318eab492aae3d41dd033c8345b044af 100644
--- a/openbis/source/sql/postgresql/166/grants-166.sql
+++ b/openbis/source/sql/postgresql/166/grants-166.sql
@@ -127,4 +127,4 @@ GRANT SELECT ON TABLE METAPROJECTS TO GROUP OPENBIS_READONLY;
 GRANT SELECT ON TABLE METAPROJECT_ASSIGNMENTS_ALL TO GROUP OPENBIS_READONLY;
 GRANT SELECT ON METAPROJECT_ASSIGNMENTS TO GROUP OPENBIS_READONLY;
 GRANT SELECT ON TABLE OPERATION_EXECUTIONS TO GROUP OPENBIS_READONLY;
-GRANT SELECT ON TABLE ANNOTATIONS TO GROUP OPENBIS_READONLY;
+GRANT SELECT ON TABLE SEMANTIC_ANNOTATIONS TO GROUP OPENBIS_READONLY;