-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Get contacts by the "number" field #19
Comments
Yes - use the GetAll OData endpoint to get the ids from the archive, then fetch the entity by id, or get the contact fields you are interested in from the archive provider.
https://docs.superoffice.com/en/api/netserver/archive-providers/reference/simplecontact.html
SimpleContact | SuperOffice Docs<https://docs.superoffice.com/en/api/netserver/archive-providers/reference/simplecontact.html>
Name Restriction Description OrderBy; getAllRows: bool: GetAll: Get all rows of archive - use with care, you may be fetching the whole database: getNoRows
docs.superoffice.com
e.g.
let odata = GET /api/v1/contact?$filter=number eq 'ABC1234'&$select=contactId,nameDepartment
Foreach( row in odata.value )
{
let contact = GET /api/v1/contact/{row.contactId}
}
…--
Christian Mogensen
Product Developer
SuperOffice AS
"Any fool can write code that a computer can understand.
Good programmers write code that humans can understand."
--Martin Fowler
________________________________
From: Sveinung ***@***.***>
Sent: 08 January 2025 15:00
To: SuperOffice/SuperOffice.WebApi-Samples ***@***.***>
Cc: Subscribed ***@***.***>
Subject: [SuperOffice/SuperOffice.WebApi-Samples] Get contacts by the "number" field (Issue #19)
Hi,
We are currently working on integrating an internal system with SuperOffice, and we have the need to get contacts by the "number" field. We are using the SuperOffice.WebApi NuGet package, and from what we can see it only has options to get contacts by their SuperOffice contact ID using ContactAgent. Is there another way to get contacts within the package? Or would we have to resort to using the REST API directly (e.g. https://docs.superoffice.com/en/api/reference/restful/rest/Contact/v1ContactEntity_GetAll.html)?
Thanks,
Sveinung
—
Reply to this email directly, view it on GitHub<#19>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AA5EUBMQVFL5E7PNOZ6WYK32JUVPFAVCNFSM6AAAAABUZ7VSKCVHI2DSMVQWIX3LMV43ASLTON2WKOZSG43TKNBXGM2TENY>.
You are receiving this because you are subscribed to this thread.Message ID: ***@***.***>
|
Thanks for the quick reply. We will look at using the OData endpoint. Are there any plans for having this functionality built into the NuGet package as well? That would be really nice since the package already handles the authentication part and has strong types. |
Hi @sveinungf! That functionality is already available in the SuperOffice.WebApi package, and is exposed via the ArchiveAgent. It is beneficial to have more knowledge about archive providers, the data sources behind OData queries. Example SimpleContact provider, based on examples in this repo: private async Task<ArchiveListItem[]> GetSimpleContactProviderResults(Tenant tenant)
{
var tenantStatus = GetTenantStatus(tenant);
if (tenantStatus.IsRunning)
{
var sysUserInfo = GetSystemUserInfo();
var sysUserTicket = await GetSystemUserTicket(sysUserInfo);
var config = new WebApiOptions(tenant.WebApiUrl);
config.Authorization = new AuthorizationSystemUserTicket(sysUserInfo, sysUserTicket);
using (ArchiveAgent agent = new ArchiveAgent(config))
{
ArchiveOrderByInfo orderBy = new ArchiveOrderByInfo { Direction = OrderBySortType.DESC, Name = "PrimaryKey" };
// restriction: number
ArchiveRestrictionInfo restriction = new ArchiveRestrictionInfo
{
Name = "number",
Operator = "=",
Values = new string[] { "ABC1234" },
IsActive = true
};
// entities - what do we want to see.
string[] desiredEntities = new string[] { "contact" };
string[] columns = new string[] { "contactId", "nameDepartment" };
// get first page, max 50 rows, of the matching invitations
ArchiveListItem[] carrier = await agent.GetArchiveListByColumnsAsync("SimpleContact", columns,
new ArchiveOrderByInfo[] { orderBy },
new ArchiveRestrictionInfo[] { restriction},
desiredEntities, 0, 50);
// for each row of the result...
foreach (ArchiveListItem row in carrier)
{
// extract and display the displayValue of each cell
// (you need to parse culturally sensitive values such as dates to get the correct client display format)
foreach (ArchiveColumnData cell in row.ColumnData.Values)
Console.Write(CultureDataFormatter.ParseEncoded(cell.DisplayValue) + "\t");
Console.WriteLine("Done...");
}
return carrier;
}
}
return null;
} |
Ah, great! Thanks for the help! |
You are welcome! By the way, I had to update the sample (that I took from docs) and adapted it to work with other examples in this repo. |
Hi,
We are currently working on integrating an internal system with SuperOffice, and we have the need to get contacts by the "number" field. We are using the
SuperOffice.WebApi
NuGet package, and from what we can see it only has options to get contacts by their SuperOffice contact ID usingContactAgent
. Is there another way to get contacts within the package? Or would we have to resort to using the REST API directly (e.g. https://docs.superoffice.com/en/api/reference/restful/rest/Contact/v1ContactEntity_GetAll.html)?Thanks,
Sveinung
The text was updated successfully, but these errors were encountered: