Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MessageResource.CreateAsync throws formatting exception when supplying C# DateTime to sendAt parameter #596

Open
zornwal opened this issue Jan 26, 2022 · 1 comment
Labels
difficulty: easy fix is easy in difficulty status: help wanted requesting help from the community type: bug bug in the library

Comments

@zornwal
Copy link

zornwal commented Jan 26, 2022

Issue Summary

Creating a message resource with the sendAt parameter set yields error response from Twilio API, stating invalid format, since wrong separators are used, . (dot) instead of : (colon)

Steps to Reproduce

  1. Create message with MessageResource.CreateAsync that has sendAt DateTime
  2. Receive exception response from API

Code Snippet

  public async Task SendSmsAsync(SmsMessage msg)
        {
            var conf = await _configurationProvider.GetConfiguration();

            await MessageResource.CreateAsync(@from: conf.From,
                to: msg.To,
                sendAt: msg.SendAt,
                scheduleType: MessageResource.ScheduleTypeEnum.Fixed,
                body: msg.Body,
                client: _twilioRestClientFactory.Create(conf));
        }

Exception/Log

API response:

{"code": 20001, "message": "Invalid SendAt: 2022-01-28T14.44.47Z. SendAt must be a valid ISO 8601 formatted datetime string: yyyy-MM-dd'T'HH:mm:ss'Z'", "more_info": "https://www.twilio.com/docs/errors/20001", "status": 400}

Exception trace (truncated):

Twilio.Exceptions.ApiException: Invalid SendAt: 2022-01-28T14.44.47Z. SendAt must be a valid ISO 8601 formatted datetime string: yyyy-MM-dd'T'HH:mm:ss'Z'
at Twilio.Clients.TwilioRestClient.ProcessResponse(Response response)
at Twilio.Clients.TwilioRestClient.RequestAsync(Request request)
at Twilio.Rest.Api.V2010.Account.MessageResource.CreateAsync(CreateMessageOptions options, ITwilioRestClient client)
at Twilio.Rest.Api.V2010.Account.MessageResource.CreateAsync(PhoneNumber to, String pathAccountSid, PhoneNumber from, String messagingServiceSid, String body, List`1 mediaUrl, Uri statusCallback, String applicationSid, Nullable`1 maxPrice, Nullable`1 provideFeedback, Nullable`1 attempt, Nullable`1 validityPeriod, Nullable`1 forceDelivery, ContentRetentionEnum contentRetention, AddressRetentionEnum addressRetention, Nullable`1 smartEncoded, List`1 persistentAction, ScheduleTypeEnum scheduleType, Nullable`1 sendAt, Nullable`1 sendAsMms, ITwilioRestClient client) [...]

Technical details:

  • twilio-csharp version: 5.70
  • csharp version: net6.0
@childish-sambino
Copy link
Contributor

This issue has been added to our internal backlog to be prioritized. Pull requests and +1s on the issue summary will help it move up the backlog.

@childish-sambino childish-sambino added difficulty: easy fix is easy in difficulty status: help wanted requesting help from the community type: bug bug in the library labels Feb 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
difficulty: easy fix is easy in difficulty status: help wanted requesting help from the community type: bug bug in the library
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants