Add debug logging for Starface create/update failures
Log the full request body and response when POST /contacts fails so we can see why new contacts are not being created. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
0f61b4cd31
commit
8a316600b5
|
|
@ -252,11 +252,20 @@ namespace StarfaceOutlookSync.Services
|
||||||
if (book.Type == "user" && !string.IsNullOrEmpty(book.UserId))
|
if (book.Type == "user" && !string.IsNullOrEmpty(book.UserId))
|
||||||
query = $"?userId={book.UserId}";
|
query = $"?userId={book.UserId}";
|
||||||
|
|
||||||
var content = new StringContent(sfContact.ToString(), Encoding.UTF8, "application/json");
|
var body = sfContact.ToString();
|
||||||
var resp = await _http.PostAsync($"{_baseUrl}/contacts{query}", content);
|
OnDebug?.Invoke($"POST /contacts{query} Body:\n{body}");
|
||||||
if (!resp.IsSuccessStatusCode) return null;
|
|
||||||
|
|
||||||
var created = JObject.Parse(await resp.Content.ReadAsStringAsync());
|
var content = new StringContent(body, Encoding.UTF8, "application/json");
|
||||||
|
var resp = await _http.PostAsync($"{_baseUrl}/contacts{query}", content);
|
||||||
|
var respBody = await resp.Content.ReadAsStringAsync();
|
||||||
|
|
||||||
|
if (!resp.IsSuccessStatusCode)
|
||||||
|
{
|
||||||
|
OnDebug?.Invoke($"POST /contacts fehlgeschlagen: {(int)resp.StatusCode} {resp.StatusCode}\n{respBody}");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
var created = JObject.Parse(respBody);
|
||||||
return MapFromStarface(created);
|
return MapFromStarface(created);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -247,6 +247,7 @@ namespace StarfaceOutlookSync.Services
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Neu -> in Starface erstellen
|
// Neu -> in Starface erstellen
|
||||||
|
Log($" Erstelle in Starface: {oc.DisplayName}");
|
||||||
var created = await starface.CreateContactAsync(oc, profile.StarfaceAddressBook);
|
var created = await starface.CreateContactAsync(oc, profile.StarfaceAddressBook);
|
||||||
if (created != null && !string.IsNullOrEmpty(created.StarfaceId))
|
if (created != null && !string.IsNullOrEmpty(created.StarfaceId))
|
||||||
{
|
{
|
||||||
|
|
@ -260,6 +261,11 @@ namespace StarfaceOutlookSync.Services
|
||||||
result.Created++;
|
result.Created++;
|
||||||
Log($" Erstellt (OL->SF): {oc.DisplayName}");
|
Log($" Erstellt (OL->SF): {oc.DisplayName}");
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Log($" FEHLER: Kontakt konnte nicht erstellt werden: {oc.DisplayName}");
|
||||||
|
result.Errors++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue