Postman Twinfield API request deleted transactions

240 views Asked by At

I'm trying to request the deleted transactions from the twinfield api. As far as I can get from the documentation I'm making a valid request with Postman but everytime I get a return code 500 -> internal server error. I'm using the following soap request:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:twin="http://www.twinfield.com/">
    <soapenv:Header>
        <twin:Header>
            <twin:AccessToken>{{Accescode}}</twin:AccessToken>
            <twin:CompanyCode>{{Company}}</twin:CompanyCode>
        </twin:Header>
    </soapenv:Header>
    <s:Body>
        <Query i:type="a:GetDeletedTransactions" xmlns="http://www.twinfield.com/" xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns:a="http://schemas.datacontract.org/2004/07/Twinfield.WebServices.DeletedTransactionsService">
            <b:CompanyCode>{{Company}}</b:CompanyCode>
            <b:Daybook>SomeDaybook</b:Daybook>
            <b:DateFrom>2021-04-01</b:DateFrom>
            <b:DateTo>2021-04-02</b:DateTo>
        </Query>
    </s:Body>
</s:Envelope>

the headersettings look the following: headersettings

I've tried it ony the company code as the rest is optional but this gave me the same result.

Any advise on how to get the return with the deleted transactions?

2

There are 2 answers

0
Tjaym On BEST ANSWER

In the end it was de XML schema that was missing, the correct XML envelope needs to look like this

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
    <s:Header>
        <h:Authentication xmlns:h="http://www.twinfield.com/" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
            <AccessToken xmlns="http://schemas.datacontract.org/2004/07/Twinfield.WebServices.Shared">{{Accescode}}</AccessToken>
            <CompanyCode xmlns="http://schemas.datacontract.org/2004/07/Twinfield.WebServices.Shared">{{Company}}</CompanyCode>
        </h:Authentication>
    </s:Header>
    <s:Body>
        <Query i:type="b:GetDeletedTransactions" xmlns="http://www.twinfield.com/" xmlns:a="http://schemas.datacontract.org/2004/07/Twinfield.WebServices" xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns:b="http://schemas.datacontract.org/2004/07/Twinfield.WebServices.DeletedTransactionsService">
            <b:CompanyCode>{{Company}}</b:CompanyCode>
            <b:DateFrom>2022-01-01T00:00:00</b:DateFrom>
            <b:DateTo>2022-12-31T23:59:00</b:DateTo>
            <b:Daybook></b:Daybook>
        </Query>
    </s:Body>
</s:Envelope>
1
jpvhnl On

your datefrom and dateto values are invalid. Those should not include the date seperators (-). this should work:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:twin="http://www.twinfield.com/">
    <soapenv:Header>
        <twin:Header>
            <twin:AccessToken>{{Accescode}}</twin:AccessToken>
            <twin:CompanyCode>{{Company}}</twin:CompanyCode>
        </twin:Header>
    </soapenv:Header>
    <s:Body>
        <Query i:type="a:GetDeletedTransactions" xmlns="http://www.twinfield.com/" xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns:a="http://schemas.datacontract.org/2004/07/Twinfield.WebServices.DeletedTransactionsService">
            <b:CompanyCode>{{Company}}</b:CompanyCode>
            <b:Daybook>SomeDaybook</b:Daybook>
            <b:DateFrom>20210401000000</b:DateFrom>
            <b:DateTo>20210402235959</b:DateTo>
        </Query>
    </s:Body>
</s:Envelope>