Add debug logging for raw Starface API contact data

Logs the first contact from Starface API response into the sync
log so we can see the actual JSON structure and fix field mapping.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
duffyduck 2026-04-03 12:13:43 +02:00
parent a3a3ac1dcc
commit 60bd3163a9
2 changed files with 11 additions and 0 deletions

View File

@ -155,11 +155,14 @@ namespace StarfaceOutlookSync.Services
return books; return books;
} }
public event Action<string> OnDebug;
public async Task<List<UnifiedContact>> GetContactsAsync(StarfaceAddressBook book) public async Task<List<UnifiedContact>> GetContactsAsync(StarfaceAddressBook book)
{ {
var contacts = new List<UnifiedContact>(); var contacts = new List<UnifiedContact>();
int page = 0; int page = 0;
const int pageSize = 200; const int pageSize = 200;
bool firstPage = true;
while (true) while (true)
{ {
@ -206,6 +209,13 @@ namespace StarfaceOutlookSync.Services
if (array.Count == 0) break; if (array.Count == 0) break;
// Ersten Kontakt als Debug-Info loggen
if (firstPage && array.Count > 0)
{
OnDebug?.Invoke($"Starface API Rohdaten (1. Kontakt):\n{array[0].ToString(Formatting.Indented)}");
firstPage = false;
}
foreach (var item in array) foreach (var item in array)
contacts.Add(MapFromStarface(item)); contacts.Add(MapFromStarface(item));

View File

@ -53,6 +53,7 @@ namespace StarfaceOutlookSync.Services
Log("Verbinde mit Starface..."); Log("Verbinde mit Starface...");
using (var starface = new StarfaceApiClient(profile.StarfaceConnection)) using (var starface = new StarfaceApiClient(profile.StarfaceConnection))
{ {
starface.OnDebug += (msg) => Log(msg);
var loginOk = await starface.LoginAsync(); var loginOk = await starface.LoginAsync();
if (!loginOk) if (!loginOk)
{ {