No header when using PaymentTransaction.transactions REST endpoint

No header when using PaymentTransaction.transactions REST endpoint

riddleydiddely
Shopify Partner
15 1 5

I using the Node.js client library to fetch balance transactions like this:

 

let options = {
        session: session,
        limit: 10,
        payout_id: 1
    }
const response = await shopify.rest.PaymentTransaction.transactions(options);

 

I only get an array with all the transactions in the response. There are no headers

 

But when I do the same thing for payouts to get the payoutId I get the data AND header. 

 

 

let options = {
        session: session,
        limit: 10,
    }
const response = await shopify.rest.Payout.all(options);

 

 

 

What I want to achieve is getting the Link for it to work with pagination and for that I need to have the header. How do fix this, is there a bug in the client?

Replies 3 (3)

Liam
Community Manager
3108 340 871

Hi Riddleydiddely! 

Have you looked into using the Shopify API Library for Ruby for this purpose? I believe you should be able to achieve what you're looking for with cursor-based pagination for REST Admin API requests, see here: https://github.com/Shopify/shopify-api-ruby/blob/main/docs/usage/rest.md#pagination

Hope this helps,

Liam | Developer Advocate @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

riddleydiddely
Shopify Partner
15 1 5

No I haven't, adding yet another language to my app adds much more complexity than I'd like, especially for only one endpoint.

 

The way got around this was to use the "With a plain REST client" approach rather than the "REST resources" approach as described in this doc.

let pageInfo: { [key: string]: any } = {
        session: session,
        limit: 10,
        date_min: startDate,
        date_max: endDate,
    }

new client.clients.Rest({session})
                .get<Payout>(
                    {
                        path: 'shopify_payments/payouts', 
                        query: pageInfo
                    }
                    )

 This returns headers with a link to the next page

riddleydiddely
Shopify Partner
15 1 5

@Liam is this bug? could you try to replicate it on your side? if so then this needs to be fixed