System.invalidoperationException: Каждый параметр в конструкторе десериализации должен связываться с свойством объекта иC#

Место общения программистов C#
Ответить Пред. темаСлед. тема
Anonymous
 System.invalidoperationException: Каждый параметр в конструкторе десериализации должен связываться с свойством объекта и

Сообщение Anonymous »

System.InvalidoPerationException: Каждый параметр в конструкторе десериализации на типе 'envvesteTextCustomFields' должен связываться с свойством объекта или полем при десериализации.
Я использую визуальную студию C#. Мне нужно получить ценность от кода JSON, поступающего из Docusign WebHook. Из сообщения об ошибке я могу понять, что я определяю env overvesteTextCustomFields неправильно. Что не так с моим форматированием?

Код: Выделить всё

{"event":"recipient-sent","apiVersion":"v2.1","uri":"/restapi/v2.1/accounts/envelopes/","retryCount":0,"configurationId":342242,"generatedDateTime":"2025-06-26T13:13:37.4471976Z","data":{"accountId":"238138292","userId":"34324324242","envelopeId":"234324234","recipientId":"1","envelopeSummary":{"status":"sent","documentsUri":"/envelopes/23432424/documents","recipientsUri":"/envelopes/2343242/recipients","attachmentsUri":"/envelopes/2343242434/attachments","envelopeUri":"/envelopes/234324244","emailSubject":"Computer","envelopeId":"42342423","signingLocation":"online","customFieldsUri":"/envelopes/2343242/custom_fields","notificationUri":"/envelopes/4545354/notification","enableWetSign":"true","allowMarkup":"false","allowReassign":"true","createdDateTime":"2025-06-26T13:13:35.9Z","lastModifiedDateTime":"2025-06-26T13:13:35.9Z","initialSentDateTime":"2025-06-26T13:13:37.383Z","sentDateTime":"2025-06-26T13:13:37.383Z","statusChangedDateTime":"2025-06-26T13:13:37.383Z","documentsCombinedUri":"/envelopes/435435345334/documents/combined","certificateUri":"/envelopes/345435345/documents/certificate","templatesUri":"/envelopes/34543535/templates","expireEnabled":"true","expireDateTime":"2025-10-24T13:13:37.383Z","expireAfter":"120","customFields":{"textCustomFields":[{"fieldId":"11212863527","name":"ComputerID","show":"false","required":"false","value":"67"}],"listCustomFields":[]},"purgeState":"unpurged","envelopeIdStamping":"true","is21CFRPart11":"false","signerCanSignOnMobile":"true","autoNavigation":"true","isSignatureProviderEnvelope":"false","uSigState":"esign","hasFormDataChanged":"false","allowComments":"true","hasComments":"false","allowViewHistory":"true","envelopeMetadata":{"allowAdvancedCorrect":"true","enableSignWithNotary":"true","allowCorrect":"true"},"anySigner":null,"envelopeLocation":"current_site","isDynamicEnvelope":"false","burnDefaultTabData":"false"}}}
< /code>
Вот мой C#, чтобы получить значение из пользовательского поля, которое имеет имя ComputerD. < /p>

List TextCustomField = new List();

int AppIDValue = 0;

foreach (var item in req.Data.EnvelopeSummary.CustomFields.TextCustomFields.ToArray())
{
if (item.getName == "ComputerID")
{
AppIDValue = Int32.Parse(item.getValue);
}
}
< /code>
Вот мои классы, чтобы определить поля, которые я хочу.  < /p>
 public class DocuSignConnectEndpoint
{
public string Event { get; set; }
public string APIVersion { get; set; }
public string URI { get; set; }
public int RetryCount { get; set; }
public int ConfigurationId { get; set; }
public DateTime GeneratedDateTime { get; set; }
public EnvelopeData Data { get; set; }
}
public class EnvelopeData
{
public string AccountId { get; set; }
public string UserId { get; set; }
public string EnvelopeId { get; set; }
public EnvelopeSummary EnvelopeSummary { get; set; }
}
public class EnvelopeSummary
{
public string Status { get; set; }
public string DocumentsUri { get; set; }
public EnvelopeCustomFields CustomFields { get; set; }

}
public class EnvelopeCustomFields
{
public List TextCustomFields { get; set; }
public List ListCustomFields
{
get; set;
}
}
public class EnvelopeTextCustomFields
{
private int FieldId;
private string Name;
private bool Show;
private bool Required;
private string Value;
public EnvelopeTextCustomFields (int FieldId, string Name, bool Show, bool Required, string Value)
{
this.FieldId = FieldId;
this.Name = Name;
this.Show = Show;
this.Required = Required;
this.Value = Value;
}
public int getFieldId
{
get { return FieldId; }
}
public string getName
{
get { return Name; }
}
public bool getShow
{
get { return Show; }
}
public bool getRequired
{
get { return Required; }
}
public string getValue
{
get { return Value; }
}
}
< /code>
Вот сообщение об ошибке: < /p>

shrong> system.invalidoperationexception: каждый параметр в конструкторе десериализации на типе 'envveloptextcustomfields' должен связываться с свойством объекта или полем на Deseriation. Поля рассматриваются только при включении «jsoneserializeroptions.includefields».  Матч может быть нечувствительным.1.OnTryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value) at System.Text.Json.Serialization.JsonConverter< /code> 1.tryread (UTF8JsonReader & Reader, Type TypetoConvert, JSONERIALIZEROPTION2.OnTryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, TCollection& value) at System.Text.Json.Serialization.JsonConverter< /code> 1.tryread (utf8jsonreader & reader, type typetoconvert, jsoneserializeroptions, readstack & state, t & value, boolean & ispopulationvalue)
at system.text.json.serialization.metadata.jsonpropertyinfo1.ReadJsonAndSetMember(Object obj, ReadStack& state, Utf8JsonReader& reader) at System.Text.Json.Serialization.Converters.ObjectDefaultConverter< /code> 1.ontryRead (UTF8JsonReader & Reader, Type TypetOconvert, JSONSERIALIZEROPTION1.TryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value, Boolean& isPopulatedValue) at System.Text.Json.Serialization.Metadata.JsonPropertyInfo< /code> 1.ReadJsonAndSetmember (Object obj, ReadStack & State, UTF8JsonReader & Reader)
at System.text.json.serialization.converters.objectDefaultConverterter1.OnTryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value) at System.Text.Json.Serialization.JsonConverter< /code> 1.tryread (utf8jsonreader & reader, type typetoconvert, jsoneserializeroptions, readstack & state, t & value, boolean & ispopulationvalue)
at system.text.json.serialization.metadata.jsonpropertyinfo1.ReadJsonAndSetMember(Object obj, ReadStack& state, Utf8JsonReader& reader) at System.Text.Json.Serialization.Converters.ObjectDefaultConverter< /code> 1.ontryRead (UTF8JsonReader & Reader, Type TypetOconvert, JSONSERIALIZEROPTION1.TryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value, Boolean& isPopulatedValue) at System.Text.Json.Serialization.Metadata.JsonPropertyInfo< /code> 1.ReadJsonAndSetmember (Object obj, ReadStack & State, UTF8JsonReader & Reader)
at System.text.json.serialization.converters.objectDefaultConverterter1.OnTryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value) at System.Text.Json.Serialization.JsonConverter< /code> 1.tryread (UTF8JsonReader & Reader, Type TypetoConvert, JSONSERIALIZEROPTION1.ReadCore(Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state) at System.Text.Json.Serialization.Metadata.JsonTypeInfo< /code> 1.continuedeserialize (readbufferstate & bufferstate, jsonreaderstate & jsonreaderstate, readstack & readstack)
at System.text.json.serialization.metadata.jsontypeinfo1.DeserializeAsync(Stream utf8Json, CancellationToken cancellationToken) at System.Text.Json.Serialization.Metadata.JsonTypeInfo< /code> 1.deserializeasobjectasync (Stream UTF8JSON, CancellationToken CancellationToken) Microsoft.aspnetcore.http.httprequestjsonextensions.readfromjsonasync (httprequest, тип типа, jsonserializeroptions, варианты Cancellationtokentoken)
at fastendpoints.requestbind1.BindJsonBody(HttpRequest httpRequest, JsonSerializerContext serializerCtx, CancellationToken ct) at FastEndpoints.RequestBinder< /code> 1.bindasync (bindercontext ctx, cancellationtoken ct)
at fastendpoints.endpoint2.BindRequestAsync(EndpointDefinition def, HttpContext ctx, List< /code> 1 сбои, CancellationToken Ct)
at fastendpoints.endpoint2.ExecAsync(CancellationToken ct) at FastEndpoints.Endpoint
2.execasync (CancellationToken CT)
at microsoft.aspnetcore.diagnostics.developerexceptionpagemiddlewareimpl.invoke (контекст httpcontext)


Подробнее здесь: https://stackoverflow.com/questions/796 ... n-construc
Реклама
Ответить Пред. темаСлед. тема

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

  • Похожие темы
    Ответы
    Просмотры
    Последнее сообщение

Вернуться в «C#»