Is there any API to get the sheets with the exact name and location?
I wanted to get the list of the sheets with the exact name I provide , also from the exact location either from workspace, folder or home. By exact name I mean returned sheets name should match complete string with given name and not just contain that string.
Answers
-
吉纳维芙P. Employee Admin
Hi@Roshan
You can use the Get / Search method to look for exact text by adding double quotes around the text you're looking for:https://smartsheet.redoc.ly/tag/search
However Search will return any Smartsheet item with that exact text, including values in cells. You'll want to then check theobjectTypeand make sure it's "sheet". ThecontextDatawill identify where the sheet is located in regards to the Workspace (either general "Sheets" or another Workspace), and then following folders.
例如,如果我找我的再保险port called "Report for Calendar App" this is what I would do:
https://api.smartsheet.com/2.0/search?query="Report for Calendar App"
Returns:
{ "results": [ { "text": "Report for Calendar App", "objectType": "report", "objectId": xxx, "contextData": [ "Genevieve's Testing Workspace > Calendar Sheets" ] } ], "totalCount": 1 }
My Workspace is吉纳维芙's Testing Workspaceand the folder isCalendarSheets.
Here's an example if I look for the text "Task 1". It shows a Sheet and a Row with this exact text. You can see that my Sheet is located in the general home "Sheets" folder.
https://api.smartsheet.com/2.0/search?query="Task 1"
{ "results": [ { "text": "Task 1", "objectType": "sheet", "objectId": xxxx, "contextData": [ "Sheets" ] }, { "text": "Task 1", "objectType": "row", "objectId": xxx, "parentObjectType": "sheet", "parentObjectId": xxx, "parentObjectName": "Find Date", "contextData": [ "Task 1" ] },
Cheers,
吉纳维芙
-
Roshan ✭
How we can use the location attribute in the search API?
-
Roshan ✭
In the search Everything API, there is a parameter called location. Could you tell me how to use it? I'm not sure if I can use this parameter to filter the result instead of iterating the API response by checking contextData.
-
吉纳维芙P. Employee Admin
Hi@Roshan
Would you be able to identify where you see the "location" parameter inthe current API Documentation?
In the Search Everything documentation the only parameter specified is the query string to search for:
The StackOverflow communitymay have some additional examples of how to use the Search Everything request.
Cheers,
吉纳维芙
-
Roshan ✭
This is one of the document where location parameters is used in search API.
https://smartsheet-platform.github.io/api-docs/?javascript#search-everything
-
吉纳维芙P. Employee Admin
Hi@Roshan
Thank you for clarifying!
This is specific to whether or not the location is in a workspace that the user owns:
location
(可选):when specified with a value ofpersonalWorkspace, limits the response to only those items in the user's workspaces.I don't believe there's a way to use this to identify a specific workspace more than the basic filter.
Cheers,
吉纳维芙