Find A User ID without Searching through ALL users
Friday, April 11, 2025 at 11:03amBelow is my logic for searching for a user to get their ID. I have > 4000 users and at 100 per call (which is the limit that appears to be enforced now) it takes forever. Is there a call I can use to get a specific users ID without all the paging below?
const int PullPageSize = 100; //was 500 but that now returns a null ptr?
try
{
OssClient oClient = new OssClient(GlobalVars.CurrentapiKey, GlobalVars.CurrentapiUrl);
int i = 1;
PageRequest npr = new PageRequest(i, PullPageSize);
IDictionary<string, Sender> accountMembers = oClient.AccountService.GetSenders(Direction.ASCENDING, npr);
while (accountMembers.Count != 0)
{
foreach (var s in accountMembers)
{
string email = s.Key.ToString().ToUpper();
string id = s.Value.Id;
//Console.WriteLine(email + " " + id);
if (email.Equals(sendereMail.ToUpper()))
return id.ToString();
i++;
}
PageRequest npr2 = new PageRequest(i, PullPageSize);
accountMembers = oClient.AccountService.GetSenders(Direction.ASCENDING, npr2);
}
}
Reply to: Find A User ID without Searching through ALL users
Tuesday, April 15, 2025 at 11:09pmHi,
It is possible without paging to get a sender and search by email address say, via the GET/api/account/senders endpoint. This takes a 'search' parameter that the email address can be passed in (make sure to URL escape the email in the parameter if doing directly via REST API). See https://community.onespan.com/products/onespan-sign/sandbox#/Senders/api.account.senders.get for a description of the parameters of this endpoint.
I see you are using our .Net SDK which does not support this search parameter currently, but you would be able to create a version of this method that passes this to our API that you can call. The below will return the sender JSON and you can extract the sender ID from there.
protected RestClient client = new RestClient(apiKey);
protected UrlTemplate template = new UrlTemplate(apiUrl);
private static readonly string ACCOUNT_MEMBER_LIST_PATH = "/account/senders?to={to}&from={from}&dir={dir}&search={search}";
public String GetSendersByEmail(Direction direction, PageRequest request, String email)
{
string path = template.UrlFor(ACCOUNT_MEMBER_LIST_PATH)
.Replace("{dir}", DirectionUtility.getDirection(direction))
.Replace("{from}", request.From.ToString())
.Replace("{to}", request.To.ToString())
.Replace("{search}", email)
.Build();
try
{
return client.Get(path);
}
catch (OssServerException e)
{
throw new OssServerException("Failed to retrieve Account Members List.\t" + " Exception: " + e.Message,
e.ServerError, e);
}
catch (Exception e)
{
throw new OssException("Failed to retrieve Account Members List.\t" + " Exception: " + e.Message, e);
}
}
This will give you most cases a single result and no paging is required.
Reply to: Find A User ID without Searching through ALL users
Tuesday, April 15, 2025 at 11:24pmThen you can get the sender ID from the JSON returned.