andrsnn
andrsnn

Reputation: 1621

Error fetching second page of transaction summary data using Token-based authentication

I recently ran into issues when using an integration record with TBA to request for multiple pages of transaction summary records when using the getPostingTransactionSummary web services action.

I found the first request was consistently successful, but following requests for successive pages would fail giving the following error:

For pages > 1, search parameters must match the original search exactly

I followed the suggestions in SuiteAnswer 33416 labeled "getPostingTransactionSummary returns an error: For pages > 1, search parameters must match the original search exactly". I then ensured we were requesting the first page first, ensured no field or filter parameters had changed, and was requesting the second page immediately.

The mechanism used to generate signature appears to be correct as all calls to any web service endpoint for the first page are always successful.

The following represents the sequence of requests used to reproduce (where real data is mocked):

Request for first page:

<x:Envelope xmlns:x="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn2="urn:messages_2015_2.platform.webservices.netsuite.com" xmlns:urn="urn:core_2015_2.platform.webservices.netsuite.com">
    <x:Header>
        <urn:tokenPassport>
            <urn1:account>1234567</urn1:account>
            <urn1:consumerKey>12345</urn1:consumerKey>
            <urn1:token>1234</urn1:token>
            <urn1:nonce>62005285</urn1:nonce>
            <urn1:timestamp>1478114023</urn1:timestamp>
            <urn1:signature algorithm="HMAC-SHA256">NIhrCvTi2SpGfhxbxO8N09WQ7mvXw7oJICiEewCtm1M=</urn1:signature>
        </urn:tokenPassport>
    </x:Header>
    <x:Body>
        <urn2:getPostingTransactionSummary>
            <urn2:fields>
                <urn:period>true</urn:period>
                <urn:account>true</urn:account>
                <urn:location>true</urn:location>
                <urn:subsidiary>true</urn:subsidiary>
            </urn2:fields>
            <urn2:filters>
                <urn:period>
                    <urn:recordRef internalId="1"/>
                    <urn:recordRef internalId="2"/>
                    <urn:recordRef internalId="3"/>
                </urn:period>
                <urn:account>
                    <urn:recordRef internalId="985" type="account"></urn:recordRef>
                </urn:account>
            </urn2:filters>
            <urn2:pageIndex>1</urn2:pageIndex>
        </urn2:getPostingTransactionSummary>
    </x:Body>
</x:Envelope>

Response for first page:

<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <soapenv:Header>
        <platformMsgs:documentInfo xmlns:platformMsgs="urn:messages_2015_2.platform.webservices.netsuite.com">
            <platformMsgs:nsId>WEBSERVICES_1234</platformMsgs:nsId>
        </platformMsgs:documentInfo>
    </soapenv:Header>
    <soapenv:Body>
        <getPostingTransactionSummaryResponse xmlns="urn:messages_2015_2.platform.webservices.netsuite.com">
            <platformCore:getPostingTransactionSummaryResult xmlns:platformCore="urn:core_2015_2.platform.webservices.netsuite.com">
                <platformCore:status isSuccess="true"/>
                <platformCore:totalRecords>2150</platformCore:totalRecords>
                <platformCore:pageSize>1000</platformCore:pageSize>
                <platformCore:totalPages>3</platformCore:totalPages>
                <platformCore:pageIndex>1</platformCore:pageIndex>
                <platformCore:postingTransactionSummaryList>
                    <platformCore:postingTransactionSummary>
                        <platformCore:period internalId="1"/>
                        <platformCore:account internalId="985"/>
                        <platformCore:subsidiary internalId="1"/>
                        <platformCore:amount>100</platformCore:amount>
                    </platformCore:postingTransactionSummary>
                    <platformCore:postingTransactionSummary>
                        <platformCore:period internalId="1"/>
                        <platformCore:account internalId="985"/>
                        <platformCore:location internalId="3"/>
                        <platformCore:subsidiary internalId="2"/>
                        <platformCore:amount>100</platformCore:amount>
                    </platformCore:postingTransactionSummary>
                    .... MORE RECORDS HERE
                </platformCore:postingTransactionSummaryList>
            </platformCore:getPostingTransactionSummaryResult>
        </getPostingTransactionSummaryResponse>
    </soapenv:Body>
</soapenv:Envelope>

Request for second page:

To be clear the only changes between the first and second request are nonce, timestamp, signature and pageIndex.

<x:Envelope xmlns:x="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn2="urn:messages_2015_2.platform.webservices.netsuite.com" xmlns:urn="urn:core_2015_2.platform.webservices.netsuite.com">
    <x:Header>
        <urn:tokenPassport>
            <urn1:account>1234567</urn1:account>
            <urn1:consumerKey>12345</urn1:consumerKey>
            <urn1:token>1234</urn1:token>
            <urn1:nonce>64687129</urn1:nonce>
            <urn1:timestamp>1478114087</urn1:timestamp>
            <urn1:signature algorithm="HMAC-SHA256">HWQ/O4MSz5L6/TRu0GhtxU37yXIHdhSqvznbG92Salg=</urn1:signature>
        </urn:tokenPassport>
    </x:Header>
    <x:Body>
        <urn2:getPostingTransactionSummary>
            <urn2:fields>
                <urn:period>true</urn:period>
                <urn:account>true</urn:account>
                <urn:location>true</urn:location>
                <urn:subsidiary>true</urn:subsidiary>
            </urn2:fields>
            <urn2:filters>
                <urn:period>
                    <urn:recordRef internalId="1"/>
                    <urn:recordRef internalId="2"/>
                    <urn:recordRef internalId="3"/>
                </urn:period>
                <urn:account>
                    <urn:recordRef internalId="985" type="account"></urn:recordRef>
                </urn:account>
            </urn2:filters>
            <urn2:pageIndex>2</urn2:pageIndex>
        </urn2:getPostingTransactionSummary>
    </x:Body>
</x:Envelope>

Response for second page:

<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <soapenv:Header>
        <platformMsgs:documentInfo xmlns:platformMsgs="urn:messages_2015_2.platform.webservices.netsuite.com">
            <platformMsgs:nsId>WEBSERVICES_1234</platformMsgs:nsId>
        </platformMsgs:documentInfo>
    </soapenv:Header>
    <soapenv:Body>
        <getPostingTransactionSummaryResponse xmlns="urn:messages_2015_2.platform.webservices.netsuite.com">
            <platformCore:getPostingTransactionSummaryResult xmlns:platformCore="urn:core_2015_2.platform.webservices.netsuite.com">
                <platformCore:status isSuccess="false">
                    <platformCore:statusDetail type="ERROR">
                        <platformCore:code>USER_ERROR</platformCore:code>
                        <platformCore:message>For pages &gt; 1, search parameters must match the original search exactly</platformCore:message>
                    </platformCore:statusDetail>
                </platformCore:status>
            </platformCore:getPostingTransactionSummaryResult>
        </getPostingTransactionSummaryResponse>
    </soapenv:Body>
</soapenv:Envelope>

The error leads me to suggest that the first request is not cached on netsuite's side correctly. I have also tried various permutations of fields in the token passport for the second request to no avail.

Any assistance appreciated.

Upvotes: 2

Views: 419

Answers (1)

andrsnn
andrsnn

Reputation: 1621

This issue was resolved by:

1) Removing the token passport node all subsequent requests (pageIndex > 1)

<x:Envelope xmlns:x="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn2="urn:messages_2015_2.platform.webservices.netsuite.com" xmlns:urn="urn:core_2015_2.platform.webservices.netsuite.com">
    <x:Header>
    </x:Header>
    <x:Body>
        <urn2:getPostingTransactionSummary>
            <urn2:fields>
                <urn:period>true</urn:period>
                <urn:account>true</urn:account>
                <urn:location>true</urn:location>
                <urn:subsidiary>true</urn:subsidiary>
            </urn2:fields>
            <urn2:filters>
                <urn:period>
                    <urn:recordRef internalId="1"/>
                    <urn:recordRef internalId="2"/>
                    <urn:recordRef internalId="3"/>
                </urn:period>
                <urn:account>
                    <urn:recordRef internalId="985" type="account"></urn:recordRef>
                </urn:account>
            </urn2:filters>
            <urn2:pageIndex>2</urn2:pageIndex>
        </urn2:getPostingTransactionSummary>
    </x:Body>
</x:Envelope>

2) Persisting and sending jsessionid and other cookies returned in headers (Set-Cookie) on first response in each subsequent request

Upvotes: 0

Related Questions