0

嗨,我正在为 Windows 桌面应用程序实现 oauth xero api。

当我使用错误的详细信息将数据推送到 xero 时,我得到 api 异常,其中包含元素,并且在元素内部它们有 ValidationError 我想获取该验证错误以向用户显示导致异常的实际错误。

下面是我在异常中得到的,但我无法从中提取验证错误消息。有没有人试过这个如果有请帮忙!

{
  "ErrorNumber": 10,
  "Type": "ValidationException",
  "Message": "A validation exception occurred",
  "Elements": [
    {
      "ContactID": "00000000-0000-0000-0000-000000000000",
      "ContactStatus": "ACTIVE",
      "Name": "Clifford Constructions Pty Ltd",
      "FirstName": "",
      "LastName": "",
      "EmailAddress": "e.gomez@cliffordconstructions.com.au",
      "TaxNumber": "96 054 514 859",
      "Addresses": [
        {
          "AddressType": "POBOX",
          "AddressLine1": "PO Box 696 ",
          "City": "HORNSBY",
          "Region": "NSW",
          "PostalCode": "1630",
          "ValidationErrors": [ ]
        }
      ],
      "Phones": [
        {
          "PhoneType": "MOBILE",
          "PhoneNumber": "",
          "ValidationErrors": [ ]
        },
        {
          "PhoneType": "DEFAULT",
          "PhoneNumber": "(02) 9482 7288",
          "ValidationErrors": [ ]
        },
        {
          "PhoneType": "FAX",
          "PhoneNumber": "(02) 9482 7037",
          "ValidationErrors": [ ]
        }
      ],
      "ContactGroups": [ ],
      "IsCustomer": true,
      "SalesTrackingCategories": [
        {
          "TrackingCategoryName": "Jobs",
          "TrackingOptionName": "TA - Training",
          "ValidationErrors": [ ]
        }
      ],
      "PaymentTerms": {
        "Sales": {
          "Day": 21,
          "Type": "DAYSAFTERBILLMONTH",
          "ValidationErrors": [ ]
        }
      },
      "ContactPersons": [
        {
          "FirstName": "James ",
          "LastName": "Handel",
          "EmailAddress": "j.handel@cliffordconstructions.com.au",
          "IncludeInEmails": false,
          "ValidationErrors": [ ]
        }
      ],
      "HasValidationErrors": true,
      "ValidationErrors": [ 
        { "Message": "There is no ACTIVE tracking option with the name 'TA - Training' for the tracking category with the name 'Jobs'" } ]
    }
  ]
}
4

0 回答 0