How to get the number of entires in SmartSheet using JAVA - smartsheet-api

I'm working with smartsheet and the problem I'm facing that I want to know whether it's crossed the maximum limit, i.e, 5000 or not before getting 400 BAD request so I can change the sheet.
can any one help me out with this thanks in advance.
Solution required in JAVA

Since there isn't an API operation that allows you to just request specifically the count of rows in a sheet, you'll need to submit a Get Sheet request for the sheet, and then evaluate the value of the totalRowCount property in the response.
To minimize the size of the response, you should set the page parameter to 1 and the pageSize parameter to 1 in the Get Sheet request. This'll make it so that only 1 row of data is included in the response (instead of the default behavior, which would return 100 rows of data).
The page in the docs I've linked to above contains a code sample for how to submit a Get Sheet request using the Smartsheet Java SDK -- but you'll need to additionally include the 2 parameters as I've described above.
(Note: I edited this answer on 3/13 to include info about the approach described below by #timwwells' comment. Thanks, Tim!)

Related

REST API Pagination in Azure Data Factory

I have a project scenario to get all values from an endpoint URL. I am using ADF Pipeline but I'm having some issues with pagination.
To get the following values, I need to make requests with the PaginationCursor value in the current body response in the following request header.
I have read that ADF supports the following case, which would be mine.
Next request’s header = property value in current response body ADF - Pagination support
I don't know how to use the following attributes in order to use the paginationCursor value from the current response body in the header of the next request.
Attributes for pagination in ADF
I tried to reproduce above but not successful. Instead, if you want to do it without pagination, you can try this approach.
First create a web activity with any page URL of your API to get the total number of pages count.
In ForEach create an array for page numbers using the count from web activity as
#range(1,activity('Web1').output.total_pages)
Inside ForEach use the copy activity and give the source REST dataset parameter for the page number like ?page=#{item()}.
In the sink dataset also, create a dataset for each page with the dataset parameter value like APIdataset#{item()}.csv. This generates the sink dataset names like APIdataset1.csv, APIdataset2.csv,...
Now, you can copy from your REST API without pagination.
My repro for your reference:
Copy activity:
I could solve this problem with the following attributes.
Solution
In the Headers I had to put the name of the header of the next call. In my case the name is PaginationCursor and I got the value of this header from the actual body response called paginationCursor.

explanation on HTTPS Records Query

Can anyone please explain how first set, previous set, next set, and the last set of records can be used to query HTTP rest message data. what exactly does this do?
I got some information in ServiceNow website, where i am not able to understand.
Can we use this instead of sysparm_limit/sysparm_offset technique to fetch the records?
Yes, it's there for pagination on your side.
To get the first 10 records you can set sysparm_limit=10 and sysparm_offset=0. To get the next 10 records you should set sysparm_limit=10 and sysparm_offset=10.

How to fetch ALL saved searches (discover) in Kibana via a REST GET?

I tried to leverage the solution described in this post using fiddler : How to change change Kibana saved search (Discover) with a REST request?
Also I had a look at: https://discuss.elastic.co/t/export-saved-objects-via-rest-api/72028/2
My problem is that even though the json returned by my get rest request has the right value for the number of definitions, it does not embed them all (only 10 out of 34 search definitions), is there like a index + count option for fetching all of them.
Ok just found a workaround, actually, I should have thought about that before...
Here is what I have done, basically listened to the queries from the browser using fiddler (using the https decrypt option) on:
Settings tab
Saved objects
Searches
It seems that there is a size parameter that I was not really aware of (like I said in my initial post, thought about an index + count / limit like in any db system)
POST my_kibana_url/elasticsearch/.kibana/visualization/_search?size=100 HTTP/1.1
{"query":{"match_all":{}}}
And look at the count value to check whether the sizes of all the requests accumulated is matching that number.

Google Analytics API TotalEvents query

I'm trying to get a total count for a give event,however I get a number much bigger(10-20 times bigger), than I see on the GA website, what am I doing wrong? (api v3)
here is the segment
metric:
ga:totalEvents
segment:
dynamic::ga:eventCategory==mycategory;ga:eventAction==myaction;ga:eventLabel==mylabel
note that I get wrong results with the query explorer as well.
You are using a segment instead of a filter.
Segments are session based so it will include all events in a session if it matches you specification. So essentially if I triggered the event you want plus other events they will all be included in the total events field.
What you need to do Is remove the segment and add a filter, the filter will include only the data you request.
Hope that helps

Can response data from core reporting api be grouped?

Explanation:
I am able to query the Google Core reporting APIv3 using the client library to get data on pageviews for specific URLs of a website I am working on. I want to get data(pageviews) for each day within a specified range. So far I am simply looping through the range, sending individual request to the API. in each request I am setting the same value for the start date and the end date.
Problem:
Obviously this gets the job done, BUT it is certainly not the best way to go about it. Because, assumming I want to get data for the past 3 months for each of about 2000 URIs. Then I will need 360000 number of requests and that value is well over the limit quota defined by Google.
Potential solution: So one way I thought of solving this issue is probably to send a request setting start-date and end-date to be a week apart but the API will return a sum of the values rather than the individual values.
main question: So is there a way to insist that these values should not be added up and returned as a sum but rather returned (as associative array or something like that) separately for each.
I hope the question is clear and that there is a solution! Thank you!
Very straightforward:
Metric: ga:pageview, Dimension: ga:date, Set a filter for your pagepath, and set a start-date and end-date.
Example:
https://www.googleapis.com/analytics/v3/data/ga?ids=ga%3Axxyyzz&dimensions=ga%3Adate&metrics=ga%3Apageviews&filters=ga%3Apagepath%3D%3D%2Ffaq.html&start-date=2013-06-27&end-date=2013-07-11&max-results=50
This will return the pageviews for that the faq.html& page for each day in the time-frame.
You should check out the QueryExplorer. Great tool to find out how to structure queries.