OrchardCMS/OrchardCore · error · ArgumentException
A message body is required in order to send a message.
Error message
A message body is required in order to send a message.
What it means
TwilioSmsProvider.SendAsync validates the SmsMessage and throws ArgumentException when message.Body is null or empty. The Twilio API requires message text (or media), so the provider rejects empty bodies before making the HTTP request.
Solutions
- Populate SmsMessage.Body with the message text before calling SendAsync.
- If the body is generated from a template, check the rendered result is non-empty before sending and log/validate otherwise.
- Catch ArgumentException around SendAsync when empty messages should be silently skipped.
- Check the workflow activity or calling code that assembles the SmsMessage actually assigns Body.
Example fix
// before
await provider.SendAsync(new SmsMessage { To = "+14155552671" });
// after
await provider.SendAsync(new SmsMessage { To = "+14155552671", Body = "Your verification code is 1234" }); Defensive patterns
Strategy: validation
Validate before calling
if (string.IsNullOrWhiteSpace(message?.Body))
return Result.Failed(new ErrorResult { Key = "BodyRequired", ErrorMessage = "A message body is required." }); Type guard
static bool HasBody(SmsMessage m) => !string.IsNullOrWhiteSpace(m?.Body);
Try / catch
try
{
await provider.SendAsync(message, ct);
}
catch (ArgumentException ex)
{
logger.LogWarning(ex, "SMS skipped: {Message}", ex.Message);
} Prevention
- Check rendered template output for emptiness before sending.
- Provide default body text in workflow Sms activities.
- Guard against localization keys resolving to empty strings.
- Validate both To and Body together in one pre-send check.
When it happens
Trigger: Calling SendAsync with an SmsMessage whose Body property is null or an empty string — e.g. a template rendered to nothing, an empty workflow property, or a message constructed with only a recipient.
Common situations: Liquid/templated SMS body evaluated to empty because the content item lacked fields; workflow Sms task configured without a body; localization returning an empty string for the message key.
Understand the failure class
Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.
Related errors
- A phone number is required in order to send a message.
- A virtual path is required
- Both the index-name and index full-name must be set.
- Cannot add model validation errors when there's no Updater…
- Cannot add model validation errors when there's no Updater…
AI-assisted analysis of OrchardCMS/OrchardCore@4306c0717f (2026-09-13).
Data as JSON: /api/errors/e71c024950965caf.
Report an issue: GitHub.
Appendix: source
Thrown at src/OrchardCore/OrchardCore.Sms.Core/Services/TwilioSmsProvider.cs:61
/// <summary>
/// Sends the specified SMS message by using the configured Twilio account.
/// </summary>
/// <param name="message">The SMS message to send.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>A <see cref="Result"/> describing whether Twilio accepted the SMS message.</returns>
public async Task<Result> SendAsync(SmsMessage message, CancellationToken cancellationToken = default)
{
ArgumentNullException.ThrowIfNull(message);
if (string.IsNullOrEmpty(message.To))
{
throw new ArgumentException("A phone number is required in order to send a message.");
}
if (string.IsNullOrEmpty(message.Body))
{
throw new ArgumentException("A message body is required in order to send a message.");
}
try
{
var settings = _options.CurrentValue;
var senderNumber = settings.PhoneNumber;
if (!string.IsNullOrEmpty(message.From))
{
senderNumber = message.From;
}
var data = new List<KeyValuePair<string, string>>
{
new ("From", senderNumber),
new ("To", message.To),
new ("Body", message.Body),View on GitHub (pinned to 4306c0717f)