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

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

Open
kjbkjb opened this issue May 11, 2023 · 2 comments
Open

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

kjbkjb opened this issue May 11, 2023 · 2 comments

Comments

@kjbkjb
Copy link

kjbkjb commented May 11, 2023

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
@twilio-dx
Copy link
Collaborator

Ahoy! Thank you for opening your first issue here! If this request is regarding troubleshooting your application, please reach out to the support team via https://support.twilio.com.

@kjbkjb
Copy link
Author

kjbkjb commented May 11, 2023

If this is an issue with Prism and not the spec, please comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants