Skip to main content

Notifications

Finance | Project Operations, Human Resources, ...
Suggested answer

Error while deserializing contract class

(0) ShareShare
ReportReport
Posted on by 30

While passing JSON from Postman hitting this,

"Message""An exception occured when deserializing the request - Exception occurred when parsing and deserializing parameter 'WLKCustomerReceiptStageList' - 'Error while deserializing contract class'",
My Contract is
[DataContractAttribute]
class WLKCustomerReceiptStageConract
{

    AccountNum              customerCode;
    LedgerJournalTransTxt   description;
    Amount                  receiptAmount;
    CurrencyCode            currency;
    ExchRate                exchangeRate;
    InvoiceId               invoiceNo;
    PaymMode                methodOFPayment,collectionCenter;
    TransDate               transDate,chequeDate; 
    WLKCustReceiptLocation  location;
    WLKIntegrationStatus    status;
    Notes                   log;
    PaymReference           paymReference; 
    PaymId                  bankName; 
    BankCentralBankPurposeCode  bankCode; 
    Voucher                 voucher; 
    [DataMemberAttribute('BankCode')]
    public BankCentralBankPurposeCode parmBankCode(BankCentralBankPurposeCode _BankCode = bankCode)
    {
        bankCode = _bankCode;
    
        return bankCode;
    }

    [DataMemberAttribute('BankName')]
    public PaymId parmBankName(PaymId _bankName = bankName)
    {
        bankName = _bankName;
    
        return bankName;
    }

    [DataMemberAttribute('ChequeDate')]
    public TransDate parmChequeDate(TransDate _chequeDate = chequeDate)
    {
        chequeDate = _chequeDate;
    
        return chequeDate;
    }

    [DataMemberAttribute('CollectionCenter')]
    public PaymMode parmCollectionCenter(PaymMode _collectionCenter = collectionCenter)
    {
        collectionCenter = _collectionCenter;
    
        return collectionCenter;
    }

    [DataMemberAttribute('Currency')]
    public CurrencyCode parmCurrency(CurrencyCode _currency = currency)
    {
        currency = _currency;
    
        return currency;
    }

    [DataMemberAttribute('CustomerCode')]
    public AccountNum parmCustomerCode(AccountNum _customerCode = customerCode)
    {
        customerCode = _customerCode;
    
        return customerCode;
    }

    [DataMemberAttribute('Description')]
    public LedgerJournalTransTxt parmDescription(LedgerJournalTransTxt _description = description)
    {
        description = _description;
    
        return description;
    }

    [DataMemberAttribute('ExchangeRate')]
    public Exchrate parmExchangeRate(Exchrate _exchangeRate = exchangeRate)
    {
        exchangeRate = _exchangeRate;
    
        return exchangeRate;
    }

    [DataMemberAttribute('InvoiceNo')]
    public InvoiceId parmInvoiceNo(InvoiceId _invoiceNo = invoiceNo)
    {
        invoiceNo = _invoiceNo;
    
        return invoiceNo;
    }

    [DataMemberAttribute('Location')]
    public WLKCustReceiptLocation parmLocation(WLKCustReceiptLocation _location = location)
    {
        location = _location;
    
        return location;
    }

    [DataMemberAttribute('Log')]
    public Notes parmLog(Notes _log = log)
    {
        log = _log;
    
        return log;
    }

    [DataMemberAttribute('MethodOfPayment')]
    public PaymMode parmMethodOfPayment(PaymMode _methodOfPayment = methodOfPayment)
    {
        methodOfPayment = _methodOfPayment;
    
        return methodOfPayment;
    }

    [DataMemberAttribute('PaymReference')]
    public PaymReference parmPaymReference(PaymReference _paymReference = paymReference)
    {
        paymReference = _paymReference;
    
        return paymReference;
    }

    [DataMemberAttribute('ReceiptAmount')]
    public Amount parmReceiptAmount(Amount _receiptAmount = receiptAmount)
    {
        receiptAmount = _receiptAmount;
    
        return receiptAmount;
    }

    [DataMemberAttribute('Status')]
    public WLKIntegrationStatus parmStatus(WLKIntegrationStatus _status = status)
    {
        status = _status;
    
        return status;
    }

    [DataMemberAttribute('Date')]
    public TransDate parmTransDate(TransDate _transDate = transDate)
    {
        transDate = _transDate;
    
        return transDate;
    }

    [DataMemberAttribute('Voucher')]
    public Voucher parmVoucher(Voucher _voucher = voucher)
    {
        voucher = _voucher;
    
        return voucher;
    }

}
 And my service class is 
[
         AifCollectionTypeAttribute("WLKCustomerReceiptStageList",Types::Class, classStr(WLKCustomerReceiptStageConract)),
        AifCollectionTypeAttribute("return",Types::Class, classStr(WLKCustomerReceiptStageConract))
    ]
    
    public List CreateCustomerReceipts(List WLKCustomerReceiptStageList)
    {
        ListIterator    iterator;
        ListEnumerator  enumerator;
        ListIterator    literator;
        WLKCustomerReceiptStageTable  wlkCustomerReceiptStageTable;
        #OCCRetryCount
        wlkCustomerReceiptStageConract       wlkCustomerReceiptStageConract;
    
        autoPostJournal = true;
    
        enumerator = WLKCustomerReceiptStageList.getEnumerator();
    
        try
        {
            ttsBegin;
            while(enumerator.moveNext())
            {
                wlkCustomerReceiptStageConract  = enumerator.current();
    
                if (wlkCustomerReceiptStageConract != null)
                {
                    wlkCustomerReceiptStageTable = this.createCustomerReceiptStage(wlkCustomerReceiptStageConract);
                    wlkCustomerReceiptStageConract.parmStatus(wlkCustomerReceiptStageTable.Status);
                    wlkCustomerReceiptStageConract.parmLog(wlkCustomerReceiptStageTable.Log);
                }
            }
    
    
           
    
    
            ttsCommit;
        }
         catch (Exception::Deadlock)
        {
            if (xSession::currentRetryCount() >= #RetryNum)
            {
                throw Exception::Deadlock;
            }
            else
            {
                retry;
            }
        }
        catch (Exception::UpdateConflict)
        {
            // try to resolve update conflict
            if (appl.ttsLevel() == 0)
            {
                if (xSession::currentRetryCount() >= #RetryNum)
                {
                    throw Exception::UpdateConflictNotRecovered;
                }
                else
                {
                    retry;
                }
            }
            else
            {
                throw Exception::UpdateConflict;
            }
        }
        catch(Exception::DuplicateKeyException)
        {
            // retry in case of an duplicate key conflict
            if (appl.ttsLevel() == 0)
            {
                if (xSession::currentRetryCount() >= #RetryNum)
                {
                    throw Exception::DuplicateKeyExceptionNotRecovered;
                }
                else
                {
                    retry;
                }
            }
            else
            {
                throw Exception::DuplicateKeyException;
            }
        }
    
        return WLKCustomerReceiptStageList;
    }
my JSON is,
{
    "WLKCustomerReceiptStageList":[
        {
            "BankCode":"Test",
            "BankName":"Test BAnk",
            "ChequeDate":"",
			"CollectionCenter":"",
            "Currency":"AED",
            "CustomerCode":"CA028007",
            "Description":"Testing Invoice Payment Integration",
            "ExchangeRate":2,
            "InvoiceNo":"INV103401/28",
            "Location":"HOC1 Cash",
			"Log":"",
            "MethodOfPayment":"Cash",
            "PaymReference":"",
            "ReceiptAmount":"100.0",
			"Status":"",
            "Date":"2023-04-13T12:00:00Z",
            "Voucher":"FHO011999/22"
           
        }
    ]
}
  • huijij Profile Picture
    huijij 19,811 on at
    RE: Error while deserializing contract class

    Hi Anoop B,

    If you have any other questions, please let us know.

  • Suggested answer
    huijij Profile Picture
    huijij 19,811 on at
    RE: Error while deserializing contract class

    Hi Anoop B,

    You must correctly specify the AifCollectionTypeAttribute attribute to use an X collection as a parameter to a service operation or as a return value. Please note the use of '' rather than "".

    [
             AifCollectionTypeAttribute('WLKCustomerReceiptStageList',Types::Class, classStr(WLKCustomerReceiptStageConract)),
            AifCollectionTypeAttribute('return',Types::Class, classStr(WLKCustomerReceiptStageConract))
        ]

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Congratulations to the January Top 10 leaders!

Check out the January community rock stars...

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,074 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 230,900 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans