SquareConnect V1 documentation indicates that pagination is supported using the Link, as shown below, in response header.
Link:<https://connect.squareup.com/v1/LOCATION_ID/payments?batch_token=BATCH_TOKEN>;rel='next'
How do I list all payments for a location, in the given date range, say 6 months, using JavaSDK? listPayments method does not provide a return value with access to pagination.
List<V1Payment> result = apiInstance.listPayments(locationId, order, beginTime, endTime, limit);
Is the only way to paginate is by slicing the date range? If so, depending on the slice size,
one might either miss transactions, as the limit is 200, if the time slice is too large
OR hit the request rate threshold, if the time slice is too small.
Appreciate any help.
If you have a time based segment (such as all transactions for the last six months) you should use the the time segment in the request and then paginate through all the responses.
The issue you are running into here is that the header based pagination tokens are not exposed in the SDK for the v1 endpoints, (nor would you be able to easily override the url with their results). You can either:
Use v2 transaction endpoints which do not use header/link based pagination
Slice the date range and iterate, like you mentioned (with its associated challenges)
Not use the SDK, and just call the v1 endpoints with your java code directly
Use some of the underlying methods of the SDK (like InvokeAPI which would be a blend between using the SDK and calling the endpoints directly.
Related
I am trying to implement pagination with the below scenario:
Third party system is hitting salesforce API and returning the result from an object in salesforce.
They want to get the results paginated and get the response from salesforce by passing below parameters from their end:
PageIndex/No
PageSize
I dont necessarily have to display the records using VisualForce/LWC,etc.Just the paginated records need to be passed back to 3rd party system.
All the resources I found on the web employ using some VF page,component,etc.If there is a necessity of using the same for implementing this pagination,please do let me know that as well.
Tried looking for resources where pagination can be implemented but the resources involve using a VF page,lightning component,etc
I expected: A simple pagination on the records being returned from the salesforce webservice
For smaller data sets you can use SOQL's LIMIT and OFFSET. You can offset (skip) up to 2000 records that way.
More general solution would be to use salesforce's "query locators" (bit like CURSOR statement in a normal database). You need to read up about queryMore() (if you use SOAP API) to get next chunk of data (no jumping around with page number, just next, next...)
REST API has similar nextRecordsUrl: https://stackoverflow.com/a/56448825/313628
If they can't implement that / you don't want to give access to normal API, just some Apex... at most you can query 50K records in 1 transaction so you could make-do something that way. You'll likely need to put some rules around fixed order of records
I will provide some context: my pipeline makes a GET Request to a REST API (Auth type: OAuth2 Client Credential) in order to import data to the Data Lake (ADLSGen2) in parquet file format. Later, a Stored Procedure creates a View which includes every file in a predefined directory.
I am looking forward to requesting data to the API on an hourly basis (or maybe every 30 minutes) in order to get information of the previous hour. The thing is: almost 36 million records are brought per hour as a response.
In the body of the response there is no reference to the number or the total of pages. There is only data (keys and values).
On the other hand, the Headers include "first-page" and "next-page" (this one appears only if there are further pages in the response, but also makes no reference to the total of pages).
I was wondering if there are any useful suggestions to make my Copy Data activity work differently. Right now, and because of what I mentioned above, the pagination rule is set to RFC5988. I would like my requested data to be partitioned in some way.
Also, I was wondering if there is another way to approach this issue (like using another activity, for example).
Thanks!
Mateo
You need to replace the Header placeholder with your header_name(Link).
Or you can directly use like this dynamic content.
I am currently using the retrieve() method to retrieve multiple charges one by one in a loop. We have a page on our app that allows a user to see the status of all payments that he is entitled to. This page takes quite a bit of time to load since we are sometimes calling \Stripe\Charge::retrieve() dozens of times in a row.
Is there anyway for me to make one call where I pass in an array of charge IDs and get info back on multiple charges from the same call? I see there is a list charges method at https://stripe.com/docs/api/charges/list, but this method doesn't allow me to pass in a list of charge IDs.
Unfortunately no, there's no way to make batch retrieval requests. However considering that you are trying to retrieve charges for a single user, you can still use the list API method and pass in the customer ID: https://stripe.com/docs/api/charges/list#list_charges-customer
Then once you have the list (probably time constrained via other properties in the list call) you can filter through and return the status of each.
I have a CosmosDB Collection which I'm querying using the REST API.
I'd like to access the total number of documents which match my query. I know I can do a count, but that means two calls, one for the count and a subsequent one to retrieve the actual records.
I would assume this is not possible in a single call, BUT.. the Data Explorer in Azure Portal seems to manage it, so just wondering if anyone has been able to figure out what calls it makes, to get this:
Showing Results 1 - 10
Retrieved document count 342
Retrieved document size 2868425 bytes
Output document count 10
It's the Retrieved Document Count I need - if the portal can do it, there ought to be a way :)
I've tried the JAVA SDK as well as REST but can't see any useful options in there either
As so often is the case in this game, asking a question triggers the answer... so apologies in advance.
The answer is to send the x-ms-documentdb-populatequerymetrics header in the request.
The response then gives a whole bunch of useful stuff in x-ms-documentdb-query-metrics.
What I would like to understand still is whether this has any performance impact?
AFAIK the ExecuteQuery handles segmented queries internally. And every request (=call to storage) for a segment counts as a transaction to the storage (I mean billing transaction - http://www.windowsazure.com/en-us/pricing/details/storage/). Right?
Is there a way to understand in how many segments is splitted a query? If I run a query and I get 5000 items, I can suppose that my query was splitted into 5 segments (due to the limit of 1000 items per segment). But in case of a complex query there is also the timeout of 5 seconds per call.
I don't believe there's a way to get at that in the API. You could set up an HTTPS proxy to log the requests, if you just want to check it in development.
If it's really important that you know, use the BeginExecuteSegmented and EndExeceuteSegmented calls instead. Your code will get a callback for each segment, so you can easily track how many calls there are.