Skip to main content
added 323 characters in body
Source Link
ckhanna
  • 3.7k
  • 1
  • 1
  • 12

In order to fetch the User by email, you will need to run two queries as below.

  1. Search for the email property on the UserProfile entity definition with the query as below.
/api/entities/query?query=Definition.Name=='M.UserProfile' AND String('Email')=='{Email_Address}'

Since email property exist on M.UserProfile entity, hence we first need to get the user profile.

  1. Once the user profile is retrieved, we can fetch the User by reading UserToUserProfile relation in the above api response.

enter image description here

This relation contains the User associated with the user profile. Using this way we can fetch the user details using email in Content Hub.

Moreover, in case you are using Web SDK, you can use following snippet to fetch user by email.

using Stylelabs.M.Base.Querying;
using Stylelabs.M.Base.Querying.Linq;
using Stylelabs.M.Framework.Essentials.LoadConfigurations;
using Stylelabs.M.Sdk.Contracts.Base;
using Stylelabs.M.Sdk.WebClient;
using Stylelabs.M.Sdk.WebClient.Authentication;
using System;
using System.Linq;
using System.Threading.Tasks;

string email = "{{EmailAddress}}";
var query = Query.CreateQuery(entities =>
            from e in entities
            where e.DefinitionName == "M.UserProfile"
            && e.Property("Email") == email
            select e);
           
var queryResult = await MClient.Querying.SingleAsync(query, EntityLoadConfiguration.Full);
var userProfileRelation = await queryResult.GetRelationAsync<IChildToOneParentRelation>("UserToUserProfile");
if (userProfileRelation != null)
{
   var userProfileId = userProfileRelation.GetId();
   var user = await MClient.Entities.GetAsync(userProfileId.Value, EntityLoadConfiguration.Full);
}

Hope this helps!!!

In order to fetch the User by email, you will need to run two queries as below.

  1. Search for the email property on the UserProfile entity definition with the query as below.
/api/entities/query?query=Definition.Name=='M.UserProfile' AND String('Email')=='{Email_Address}'

Since email property exist on M.UserProfile entity, hence we first need to get the user profile.

  1. Once the user profile is retrieved, we can fetch the User by reading UserToUserProfile relation in the above api response.

enter image description here

This relation contains the User associated with the user profile. Using this way we can fetch the user details using email in Content Hub.

Moreover, in case you are using Web SDK, you can use following snippet to fetch user by email.

string email = "{{EmailAddress}}";
var query = Query.CreateQuery(entities =>
            from e in entities
            where e.DefinitionName == "M.UserProfile"
            && e.Property("Email") == email
            select e);
           
var queryResult = await MClient.Querying.SingleAsync(query, EntityLoadConfiguration.Full);
var userProfileRelation = await queryResult.GetRelationAsync<IChildToOneParentRelation>("UserToUserProfile");
if (userProfileRelation != null)
{
   var userProfileId = userProfileRelation.GetId();
   var user = await MClient.Entities.GetAsync(userProfileId.Value, EntityLoadConfiguration.Full);
}

Hope this helps!!!

In order to fetch the User by email, you will need to run two queries as below.

  1. Search for the email property on the UserProfile entity definition with the query as below.
/api/entities/query?query=Definition.Name=='M.UserProfile' AND String('Email')=='{Email_Address}'

Since email property exist on M.UserProfile entity, hence we first need to get the user profile.

  1. Once the user profile is retrieved, we can fetch the User by reading UserToUserProfile relation in the above api response.

enter image description here

This relation contains the User associated with the user profile. Using this way we can fetch the user details using email in Content Hub.

Moreover, in case you are using Web SDK, you can use following snippet to fetch user by email.

using Stylelabs.M.Base.Querying;
using Stylelabs.M.Base.Querying.Linq;
using Stylelabs.M.Framework.Essentials.LoadConfigurations;
using Stylelabs.M.Sdk.Contracts.Base;
using Stylelabs.M.Sdk.WebClient;
using Stylelabs.M.Sdk.WebClient.Authentication;
using System;
using System.Linq;
using System.Threading.Tasks;

string email = "{{EmailAddress}}";
var query = Query.CreateQuery(entities =>
            from e in entities
            where e.DefinitionName == "M.UserProfile"
            && e.Property("Email") == email
            select e);
           
var queryResult = await MClient.Querying.SingleAsync(query, EntityLoadConfiguration.Full);
var userProfileRelation = await queryResult.GetRelationAsync<IChildToOneParentRelation>("UserToUserProfile");
if (userProfileRelation != null)
{
   var userProfileId = userProfileRelation.GetId();
   var user = await MClient.Entities.GetAsync(userProfileId.Value, EntityLoadConfiguration.Full);
}

Hope this helps!!!

added 755 characters in body
Source Link
ckhanna
  • 3.7k
  • 1
  • 1
  • 12

In order to fetch the User by email, you will need to run two queries as below.

  1. Search for the email property on the UserProfile entity definition with the query as below.
/api/entities/query?query=Definition.Name=='M.UserProfile' AND String('Email')=='{Email_Address}'

Since email property exist on M.UserProfile entity, hence we first need to get the user profile.

  1. Once the user profile is retrieved, we can fetch the User by reading UserToUserProfile relation in the above api response.

enter image description here

This relation contains the User associated with the user profile. Using this way we can fetch the user details using email in Content Hub.

Moreover, in case you are using Web SDK, you can use following snippet to fetch user by email.

string email = "{{EmailAddress}}";
var query = Query.CreateQuery(entities =>
            from e in entities
            where e.DefinitionName == "M.UserProfile"
            && e.Property("Email") == email
            select e);
           
var queryResult = await MClient.Querying.SingleAsync(query, EntityLoadConfiguration.Full);
var userProfileRelation = await queryResult.GetRelationAsync<IChildToOneParentRelation>("UserToUserProfile");
if (userProfileRelation != null)
{
   var userProfileId = userProfileRelation.GetId();
   var user = await MClient.Entities.GetAsync(userProfileId.Value, EntityLoadConfiguration.Full);
}

Hope this helps!!!

In order to fetch the User by email, you will need to run two queries as below.

  1. Search for the email property on the UserProfile entity definition with the query as below.
/api/entities/query?query=Definition.Name=='M.UserProfile' AND String('Email')=='{Email_Address}'

Since email property exist on M.UserProfile entity, hence we first need to get the user profile.

  1. Once the user profile is retrieved, we can fetch the User by reading UserToUserProfile relation in the above api response.

enter image description here

This relation contains the User associated with the user profile. Using this way we can fetch the user details using email in Content Hub.

Hope this helps!!!

In order to fetch the User by email, you will need to run two queries as below.

  1. Search for the email property on the UserProfile entity definition with the query as below.
/api/entities/query?query=Definition.Name=='M.UserProfile' AND String('Email')=='{Email_Address}'

Since email property exist on M.UserProfile entity, hence we first need to get the user profile.

  1. Once the user profile is retrieved, we can fetch the User by reading UserToUserProfile relation in the above api response.

enter image description here

This relation contains the User associated with the user profile. Using this way we can fetch the user details using email in Content Hub.

Moreover, in case you are using Web SDK, you can use following snippet to fetch user by email.

string email = "{{EmailAddress}}";
var query = Query.CreateQuery(entities =>
            from e in entities
            where e.DefinitionName == "M.UserProfile"
            && e.Property("Email") == email
            select e);
           
var queryResult = await MClient.Querying.SingleAsync(query, EntityLoadConfiguration.Full);
var userProfileRelation = await queryResult.GetRelationAsync<IChildToOneParentRelation>("UserToUserProfile");
if (userProfileRelation != null)
{
   var userProfileId = userProfileRelation.GetId();
   var user = await MClient.Entities.GetAsync(userProfileId.Value, EntityLoadConfiguration.Full);
}

Hope this helps!!!

Source Link
ckhanna
  • 3.7k
  • 1
  • 1
  • 12

In order to fetch the User by email, you will need to run two queries as below.

  1. Search for the email property on the UserProfile entity definition with the query as below.
/api/entities/query?query=Definition.Name=='M.UserProfile' AND String('Email')=='{Email_Address}'

Since email property exist on M.UserProfile entity, hence we first need to get the user profile.

  1. Once the user profile is retrieved, we can fetch the User by reading UserToUserProfile relation in the above api response.

enter image description here

This relation contains the User associated with the user profile. Using this way we can fetch the user details using email in Content Hub.

Hope this helps!!!