Repository navigation
SDK sending empty message even though message object is initialized #3181
Replies: 1 comment
|
The cause is the SDK's backing store. Graph models only serialize properties marked as changed. After any serialization through the SDK's serializers, all properties are marked clean ( It also explains the occasional first-attempt failure, if anything serialized the object before the send. A common culprit is logging it with Fixes: // before re-sending an object that was already serialized
message.BackingStore.InitializationCompleted = false; // marks all properties dirty again
await graphClient.Users[userId].SendMail.PostAsync(body);For logging, ask for the full object so the dirty flags are left alone: var json = await KiotaJsonSerializer.SerializeAsStringAsync(message, serializeOnlyChangedValues: false);Building a new |
Uh oh!
There was an error while loading. Please reload this page.
I have an application that uses the GraphAPI SDK version 6.70 to send emails. On occasion I have seen a 400 error claiming that there were no valid recipients in the email. This is reinforced by the fact that logging the raw HTTP request shows an empty message. However, I am logging the contents of the Message object before and after sending, and in both cases it is properly initialized including a TO recipient, subject and body. Retrying using the same message object fails again with another 400. However, if I create a new message object and send that it usually succeeds. Any ideas?
All reactions