I’m submitting a…
- [ ] Regression (a behavior that stopped working in a new release)
- [X] Bug report
- [ ] Performance issue
- [ ] Documentation issue or request
Environment
- [ ] Self hosted with docker
- [X] Self hosted with IIS
- [ ] Self hosted with other version
- [ ] Cloud version
Version: 3.1.0
Squidex.ClientLibrary: 3.7.0
Others:
Client Manager .Net Core
I have a scheme and corresponding models:
public sealed class Customer : SquidexEntityBase<CustomerData>
{
}
public class CustomerData
{
[JsonConverter(typeof(InvariantWriteConverter))]
[JsonProperty("fullName")]
public string FullName { get; set; }
[JsonConverter(typeof(InvariantWriteConverter))]
[JsonProperty("customerNumber")]
public int CustomerNumber { get; set; }
[JsonConverter(typeof(InvariantWriteConverter))]
[JsonProperty("address")]
public string Address { get; set; }
[JsonConverter(typeof(InvariantWriteConverter))]
[JsonProperty("country")]
public string Country { get; set; }
[JsonConverter(typeof(InvariantWriteConverter))]
[JsonProperty("email")]
public string Email { get; set; }
[JsonConverter(typeof(InvariantWriteConverter))]
[JsonProperty("phone")]
public string Phone { get; set; }
[JsonConverter(typeof(InvariantWriteConverter))]
[JsonProperty("sendNewsletter")]
public bool SendNewsletter { get; set; }
}
Service Code:
public async Task<Result<Customer>> PostCustomerAsync(CustomerData model)
{
try
{
var client = _clientManager.GetClient<Customer, CustomerData>("customer");
var result = await client.CreateAsync(model);
return await result.ToResultAsync();
}
catch (Exception ex)
{
_logger.LogError(ex.Message, ex);
return new Result<Customer>(new Customer(), StatusTypes.Error, ex.Message);
}
}
The JSON file which is transmitted in my case is:
{
"fullName": "Andreas",
"customerNumber": 100001,
"address": "Musterstrasse 99\n9000 St. Gallen",
"country": "Schweiz",
"email": "andreas@webnerds.ch",
"phone": "+41 (0)00 000 00 00",
"sendNewsletter": true
}
If I run the code now, a record will be created, but there will be an error:
“Cannot deserialize the current JSON object (e.g. {“name”:“value”}) into type ‘System.String’ because the type requires a JSON primitive value (e.g. string, number, boolean, null) to deserialize correctly. To fix this error either change the JSON to a JSON primitive value (e.g. string, number, boolean, null) or change the deserialized type so that it is a normal .NET type (e.g. not a primitive type like integer, not a collection type like an array or List) that can be deserialized from a JSON object. JsonObjectAttribute can also be added to the type to force it to deserialize from a JSON object. Path ‘data.fullName.iv’, line 1, position 153.”