I am using a shopifySharp library Order entity to map Shopify orders with the class object. The problem is that some properties are mapping fine but some are not.
I am not getting why this behavior is happening.
public class Order
{
[JsonProperty("id")]
public long? Id { get; set; }
[JsonProperty("admin_graphql_api_id")]
public string AdminGraphQLAPIId { get; set; }
[JsonProperty("app_id")]
public long? AppId { get; set; }
}
The complete object is available on
CodePudding user response:
Your API is probably using System.Text.Json
serializer. There is nothing wrong with your object, but it will only work correctly with Newtonsoft
.
In order to make your API use Newtonsoft
you need to configure it in Startup
:
services.AddControllers().AddNewtonsoftJson();
Edit:
If you are not bound to any specific Newtonsoft
feature, you can also just use the official json serializer from Microsoft: System.Text.Json
, which is more performant, but for that you need to add to your object the attribute [JsonPropertyName("your_prop")]
.