调用Abenity API遇报错:需提供Creation Time(creation_time)
Let's get this sorted out—your error message spells out exactly what's missing: the creation_time parameter is mandatory for the Abenity SSO Member API, but your payload isn't including it. Here's how to resolve this step by step:
1. Ensure your SsoMemberPayload class includes the required property
First, check if your SsoMemberPayload model has a property mapped to creation_time. Abenity's API expects this field in snake_case, so you need to make sure the property is correctly configured for serialization. For example, in C#:
public class SsoMemberPayload { // Your existing properties here... [JsonPropertyName("creation_time")] // Use this if using System.Text.Json // OR [DataMember(Name = "creation_time")] if using Newtonsoft.Json public DateTime CreationTime { get; set; } }
If this property was missing entirely, that's the root cause—add it to your model class.
2. Populate the CreationTime value in your payload
Once the property exists, you need to set it when creating your SsoMemberPayload instance. Abenity accepts valid timestamps (typically ISO 8601 format), so using UTC time is a safe choice to avoid timezone inconsistencies:
abenityApi.PostSsoMember(new SsoMemberPayload() { Address = "1 Main St.", City = "Nashville", ClientUserId = "1", Country = "US", Email = "jane.doe@maildomain.com", Username = "jane.doe@maildomain.com", FirstName = "Jane", LastName = "Doe", SendWelcomeEmail = true, State = "TN", Zip = "37201", CreationTime = DateTime.UtcNow // Use UTC time for consistent timestamps });
3. Verify serialization settings
If you already had the property but still get the error, confirm your JSON serializer is correctly converting the CreationTime property to creation_time (snake_case). Depending on whether you're using System.Text.Json or Newtonsoft.Json, you can either rely on the attribute added in step 1, or adjust global serialization settings to auto-convert PascalCase to snake_case.
4. Check for outdated SDK issues
If you're using an official Abenity SDK, an older version might not auto-populate creation_time for you. Try updating to the latest SDK version and review its documentation—some SDKs handle this field automatically, but if yours doesn't, manual setting is necessary.
Once you add and properly configure the creation_time parameter, your API call should work as expected.
内容的提问来源于stack exchange,提问作者Amit Mishra

