Skip to content

Date fields do not contain date values, instead "string" #92

Open
@kjbkjb

Description

Issue Summary

Wrongly typed data for dates. Dummy dates are returned with the string literal "string" as the value which blows up in the json parser.

Steps to Reproduce

  1. Using the Twilio c# rest client library, perform an AccountResource.Create action

Code Snippet

            
var account = AccountResource.Create(
                friendlyName: $"SMS Provider Account (orgId: {organizationId})",
                client: client
           );

//The mock server responds with incorrect data for all date fields:
//{\"auth_token\":\"string\",\"date_created\":\"string\",\"date_updated\":\"string\",\"friendly_name\":\"string\",\"owner_account_sid\":\"stringstringstringstringstringstri\",\"sid\":\"stringstringstringstringstringstri\",\"status\":\"active\",\"subresource_uris\":{},\"type\":\"Trial\",\"uri\":\"string\"}"

  // from the Twilio rest client library, the json parsing throws type errors for dates (below)
    public static AccountResource Create(CreateAccountOptions options, ITwilioRestClient client = null)
    {
      client = client ?? TwilioClient.GetRestClient();
      return AccountResource.FromJson(client.Request(AccountResource.BuildCreateRequest(options, client)).Content);
    }

Exception/Log

Twilio.Exceptions.ApiException
Could not convert string to DateTime: string. Path 'date_created', line 1, position 46.
   at Twilio.Rest.Api.V2010.AccountResource.FromJson(String json)
   at Twilio.Rest.Api.V2010.AccountResource.Create(CreateAccountOptions options, ITwilioRestClient client)
   at Twilio.Rest.Api.V2010.AccountResource.Create(String friendlyName, ITwilioRestClient client)
   at TotalExpert.Comms.Sms.TwilioManagement.SubaccountCreator.CreateSubaccount(LegacyId organizationId) in /Users/kevin.boedigheimer/totalexpert/sms-service/CommandProcessor/TwilioManagement/SubaccountCreator.cs:line 28

Newtonsoft.Json.JsonReaderException
Could not convert string to DateTime: string. Path 'date_created', line 1, position 46.
   at Newtonsoft.Json.JsonReader.ReadDateTimeString(String s)
   at Newtonsoft.Json.JsonTextReader.FinishReadQuotedStringValue(ReadType readType)
   at Newtonsoft.Json.JsonTextReader.ReadStringValue(ReadType readType)
   at Newtonsoft.Json.JsonTextReader.ReadAsDateTime()
   at Newtonsoft.Json.JsonReader.ReadForType(JsonContract contract, Boolean hasConverter)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
   at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)
   at Newtonsoft.Json.JsonSerializer.Deserialize(JsonReader reader, Type objectType)
   at Newtonsoft.Json.JsonConvert.DeserializeObject(String value, Type type, JsonSerializerSettings settings)
   at Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value, JsonSerializerSettings settings)
   at Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value)
   at Twilio.Rest.Api.V2010.AccountResource.FromJson(String json)

Technical details:

  • twilio-oai version: twilio_api_v2010
  • c# client library version: 6.2.2

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions