Filter options in smartsheet API or SDK - smartsheet-api

I am currently exploring the smartsheet API 2.0. I want to filter based on Modified and Created date but I am unable to find any such option in the documentation.
Is there a way out to filter the smartsheet using any custom filter as we have in oData API. e.g
<API URL>?$filter= createdDate ge '10/06/2019' or modified ge '10/06/2019'

You need to create your filters in smartsheet since they can not be created on wire over API.
Then you can call
https://api.smartsheet.com/2.0/sheets/{id}?filterId={ID}&exclude=filteredOutRows
P.S You need to enter id of your filter not the name of the filter.

You can create a sheet filter, and then filter the rows via the API using the include=filters param.
See the docs for more details.

There isn't any way to send a filter query, some alternatives :
You can create a filter on the fly such as described below.
Or you can read all the sheet content and then filter on you own
In c# filtering row would look like this:
var ssclient = new SmartsheetBuilder().SetAccessToken(token).Build();
m.Sheet sheet = ssclient.SheetResources.GetSheet(sheetId, null, null, null, null, null, null, null);
List<m.Row> rowsModifiedToday = sheet.Rows.Where(r => DateTime.ParseExact(r.Cells[columnIndex].Value.ToString(), "dd/MM/yy", null) >= DateTime.Today).ToList();

Related

How to retrieve stats for dynamic templates via Sendgrid API

I'm looking for help on how to retrieve stats for dynamic templates via SG API using curl.
Using https://api.sendgrid.com/v3/templates?generations=dynamic I've been able to get
specific template info but I can't seem to successfully use the dynamic template_id
and version id or subject id to pull stats for each email under the main template_id.
I get success returns for all stats using https://api.sendgrid.com/v3/stats?start_date=2022-05-01
but when I try to add template_id or any other param it's ignored by the API.
Any ideas? Thanks.
In the documentation for the global email statistics API the available query parameters that you can provide are:
limit
offset
aggregated_by - can be "day", "week" or "month"
start_date - as you used in your example
end_date
You cannot filter by the template, version or subject.

Magento1.9 Rest Api filters

How to get rest api data filterable by updated_at attribute in Magento1?
I would like my rest API data to be filtered by last updated_at so I have tried something like this:-
http://localhost/mage1/products?page=1&limit=5&filter[0][attribute]=updated_at&filter[0][gteq]=2019-09-01 07:40:30
I have tried the filters shown on devdocs for M1 but didn't succeeded with any proper result. https://prnt.sc/p0lrk9
https://localhost/api/rest/products?filter[0][attribute]=updated_at&filter[0][from][0]=max_date&page=1&limit=100&order=updated_at&dir=asc"
This may help you.It worked for me

DOMINO REST API get Collection sort column

Hi I'm trying to get a sorted Collection from the Domino Rest Api. My database name is "Test/JSON_Views.nsf" and my views name "List".
The endpoint I use is
**/Test/JSON_Views.nsf/api/data/collections/name/List?sortcolumn=title&sortorder=ascending&count=20
But the JSON-Response entries aren't sorting by title in ascending order.
Should I make any settings to the column properties in the designer? If I set descending there for the title-column it works. But I want to change the sorting in my external java-application.
Is my endpoint correct? I use this Domino API Docu as Reference.
Add an additional sorting to your title column:
This gives the API the possibility to sort by title in both directions. You can do this with other columns too so you are very flexible in sorting this way.
The doc says that if the column isn't sorted in design then the sortcolumn parameter has no effect, so the answer is "Yes" you should change the design of the desired column. If doing that is unworkable in whatever context you use it, then create a second view and use that instead.

Using Smartsheet API 2.0 how to get ONLY the 'modifiedAt' property of a specific sheet

I need to get the last modified timestamp property of a sheet using Smartsheet API 2.0 (preferably Python SDK).
Ref:
https://smartsheet-platform.github.io/api-docs/
https://github.com/smartsheet-platform/smartsheet-python-sdk
Using Sheets.list_sheets I am able to get the 'modifiedAt' property (along with other properties) for all the sheets that I have access to.
Using Sheets.get_sheet(sheet_id) I get all the data (rows, columns) for the specified sheet.
How do I get only the 'modifiedAt' (it's OK if some other small properties are also present) for a specific sheet with a known sheet ID. I don't want the row, column, cell information to be present in the API response.
I wrote to Smartsheet support team and their answer served my purpose.
Thanks for contacting Smartsheet Support. In order to narrow down the
response that you're getting, you can use the exclude parameter:
http://smartsheet-platform.github.io/api-docs/#query-strings. In my
testing, I excluded all rows and columns where columnIds=0 and
rowIds=0. That left me with only the Sheet information, which includes
the modifiedAt for the sheet. You may be able to limit it further, but
the result I got from this was pretty short and sweet.
(Python SDK example)
response = ss_client.Sheets.get_sheet(MY_SHEET_ID, column_ids='0', row_ids = '0')
Using the above parameters, I was able to exclude all the sheet data and got only the metadata (which included modifiedAt property).
Basically my intention was to run a sync script periodically and store the Smartsheet data into my local db. I wanted the API response to skip the actual Sheet data (rows, columns, cells) if nothing would have changed since the last execution. Another nifty way of achieving this to use the ifVersionAfter parameter.
ifVersionAfter (optional): If version specified is still the current
sheet version, then returns an abbreviated Sheet object with only the
sheet version property. Otherwise, if the sheet has been modified,
returns the complete Sheet object. Intended to allow clients with a
cached copy to make sure they have the latest version.
last_version_fetched = 7724
response = ss_client.Sheets.get_sheet(MY_SHEET_ID, if_version_after=last_version_fetched)
The Get Sheet call will always return the content (row, column, data) from a specific sheet. While there is an 'exclude' query parameter that can filter out some properties, it does not work on the primary sheet data returned from the /sheets/{sheetId} endpoint.
The Sheets.list_sheets call seems like the easier route if you only need the modifiedAt property. I would use that one then iterate over the results until you find the matching id.

jcr sql-2 get node name

i am working on aem 6.3 and would like to get page name
SELECT * FROM [cq:Page] WHERE ISDESCENDANTNODE("/content/Product/Silhouettes/Accessories/Bands/Headband")
If I need to retrieve name of the nodes using sql-2 , how do I achieve it?
You can specify column constraints like title, node name, etc this way -
SELECT nodeSet.name, nodeset.title
FROM [cq:Page] AS nodeSet
WHERE ISDESCENDANTNODE("/content/Product/Silhouettes/Accessories/Bands/Headband")
Note: the query tool in AEM(Tools -> Query) will not list the query results according to the columns you've mentioned, it will only list the node paths.
You can look at using /etc/importers/bulkeditor.html or AEM fiddle tool to visualize the query results based on column constraints.
If you want to achieve this programmatically, you can use the same query as you've mentioned in your question and use javax.jcr.query.* and javax.jcr.Node.* API's to retrieve just about any property from the query result. This article here should help you achieve this programatically.
Use the ResourceResolver API to execute and obtain the query results:
final Iterator<Resource> pagesIterator = resolver.findResources('<your_query_here>', javax.jcr.query.Query.JCR_SQL2);
while (pagesIterator.hasNext()) {
final Resource pageResource = pagesIterator.next();
LOG.info(pageResource.getName());
}
However, please note that if you are using any version higher then CQ 5.6, you should use instead the Page API.
In this case, the listChildren(Filter<Page> filter, boolean deep) method will do the job.
The PageFilter parameter may be used if you want to filter through pages of some kind. So if no extra criteria for your page finding algorithm, your may pass null or a new empty object.
The boolean parameter: if false it returns only direct child pages, and if true would list all the descendant pages of the given page.
Therefore, the equivalent solution of the SQL Query which would provide you the same end results would be:
Iterator<Page> rootPageIterator = rootPage.listChildren(null, true);