Entity, CreateAsync from Client, Cloud edition > SquidexException

Hi,

In cloud edition, when creating a content from the client I get the following error :

SquidexException: Squidex Request failed: {“message”:“Failed to create content.”,“details”:[“Date: Not a valid value.”,“body: Not a known field.”,“date: Not a known field.”,“phone: Not a known field.”,“email: Not a known field.”,“identity: Not a known field.”],“statusCode”:400}
Squidex.ClientLibrary.SquidexClientBase.EnsureResponseIsValidAsync(HttpResponseMessage response, string token)

Here is my method :

var message = new MessageData { Date = DateTime.Now, Body = Lorem.Words(350), Email = Lorem.Email(), Identity = Lorem.Words(2), Phone = “0607358880” };

var response = await apiClient.SaveMessage(message);

return new JsonResult(response);

Here is my apiClient call implementation :

public ApiClient(IOptions appOptions)
{
var options = appOptions.Value;

        var clientManager = new SquidexClientManager(
                options.Url,
                options.AppName,
                options.ClientId,
                options.ClientSecret);

        messages = clientManager.GetClient<Message, MessageData>("message");
    }

public async Task SaveMessage(MessageData message)
{
return await messages.CreateAsync(message, true);
}

Here is my MessageData class :

public sealed class MessageData
{

    [JsonConverter(typeof(InvariantConverter))]
    public string Identity { get; set; }

    [JsonConverter(typeof(InvariantConverter))]
    public string Email { get; set; }

    [JsonConverter(typeof(InvariantConverter))]
    public string Phone { get; set; }

    [JsonConverter(typeof(InvariantConverter))]
    public DateTime Date { get; set; }

    [JsonConverter(typeof(InvariantConverter))]
    public string Body { get; set; }
}

The Schema in cloud :

{
“fields”: [
{
“name”: “Date”,
“properties”: {
“editor”: “DateTime”,
“isListField”: true,
“fieldType”: “DateTime”
},
“partitioning”: “invariant”
},
{
“name”: “Identity”,
“properties”: {
“editor”: “Input”,
“isRequired”: true,
“isListField”: true,
“fieldType”: “String”
},
“partitioning”: “invariant”
},
{
“name”: “Phone”,
“properties”: {
“editor”: “Input”,
“isListField”: true,
“fieldType”: “String”
},
“partitioning”: “invariant”
},
{
“name”: “Email”,
“properties”: {
“editor”: “Input”,
“isRequired”: true,
“isListField”: true,
“fieldType”: “String”,
“pattern”: “^[a-zA-Z0-9.!#$%&’+\/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:.[a-zA-Z0-9-]+)$”
},
“partitioning”: “invariant”
},
{
“name”: “Body”,
“properties”: {
“editor”: “TextArea”,
“isRequired”: true,
“fieldType”: “String”
},
“partitioning”: “invariant”
}
],
“properties”: {}

Am I doing something wrong in my implementation ?

Regards

Can you fix the formatting please?

I do not understand what formatting should I fix ! This post in support or the formatting of my classes ?

Apparently my objects are serialized with lowercase property names when sent to cloud…

I mean the post :wink:

Property names in squidex are case-sensitive, but the client library converts pascal case to camel case by default. Therefore you see these errors. You can use the [KeepCasing] attribute to fix it.

Ok done that.

In what format Dates should be expressed ?

Thx

Ok, dates need to be zulu time.

Thanks for the [KeepCasing] attribute !

IS8601, it should be default format with JSON.NET

This attribute isn’t in the latest nuget (v 1.3.0). How shall we deal with this issue in the future? I had the same problem as the OP and had to roll back to v 1.10. The current code in the ToContent extension appears to have no accomodation for this need.

Sorry, then something went wrong when deploying the current version. I will release a new version today.

1 Like

I uploaded a new version.

1 Like