Fix Starface JSON parsing and Outlook folder/contact reading
Starface API: - Handle both array and object responses from /contacts endpoint - Try common wrapper fields (items, contacts, data, results) Outlook contacts: - Add FindFolderByPath that matches exact FolderPath property - Fallback to Namespace.Folders navigation if store lookup fails - Fallback: try reading contact fields even if Class != 40 - Add debug logging for folder path and item count Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -172,7 +172,38 @@ namespace StarfaceOutlookSync.Services
|
||||
var resp = await _http.GetAsync($"{_baseUrl}/contacts?{query}");
|
||||
if (!resp.IsSuccessStatusCode) break;
|
||||
|
||||
var array = JArray.Parse(await resp.Content.ReadAsStringAsync());
|
||||
var body = await resp.Content.ReadAsStringAsync();
|
||||
JArray array;
|
||||
|
||||
// Die API gibt je nach Version ein Array oder ein Objekt mit "items" zurueck
|
||||
var token = JToken.Parse(body);
|
||||
if (token is JArray directArray)
|
||||
{
|
||||
array = directArray;
|
||||
}
|
||||
else if (token is JObject obj)
|
||||
{
|
||||
// Versuche gaengige Felder: items, contacts, data, results
|
||||
array = (obj["items"] ?? obj["contacts"] ?? obj["data"] ?? obj["results"]) as JArray;
|
||||
if (array == null)
|
||||
{
|
||||
// Einzelnes Kontakt-Objekt? Dann in Array wrappen
|
||||
if (obj["id"] != null && obj["blocks"] != null)
|
||||
{
|
||||
array = new JArray { obj };
|
||||
}
|
||||
else
|
||||
{
|
||||
System.Diagnostics.Debug.WriteLine($"Unerwartete Starface-Antwort: {body.Substring(0, Math.Min(200, body.Length))}");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
if (array.Count == 0) break;
|
||||
|
||||
foreach (var item in array)
|
||||
|
||||
Reference in New Issue
Block a user