I have a task to automate a process which starts with a Smartsheet. I’m somehow new to FME. Does anyone know how can I add the Smartsheet to my workbench as a reader.
Thanks @hkingsbury. I’ve checked the two links. The first step is to executing API requests using a tool like cURL or Postman, then create an access token, then use HTTPCaller?
This would be in the _request_body property of the feature that comes out of the HTTPCaller.
There is a ‘totalPages’ attribute that tells you in this case you have a single page. If not, you should follow up with a second call to request the next page.
Then there is a ‘data’ attribute within the JSON, that you can extract with a JSONExtractor. And a JSONFragmenter to make multiple features with the properties available.
And then you can make a next request to the permalink for example to get the next step.
Is it possible to parse all the sheet just with jsonFragmenter? do you think it is correct to set the JSON Query to json["columns"][]["rows"][] and in attribute to expose enter all the columns headings?
I’m not sure if the result of HttpCaller is correct. the first when I set the format of result to json it will not change the format. The response-body has all the data of the sheet but it start with information about name of the sheet, sheet D, my level of access. is that ok?
I’ve never used SmartSheets before so unsure exactly what the API is expected to return. However looking at this:
this is a part of error I got:
Your response body seems valid and something I would expect to be returned from an API. Your JSON query isn’t valid, which will explain why its not working.
@hkingsbury @farzaneh.ahmadi Hi guys, did you all end up figuring this out? I am actually looking into if it’s possible to do this same exact thing...updating SmartSheet projects from FME.
I have used FME with SmartSheet’s API and the way I did it was with the HTTPCaller (You can also use OpenAPICaller) to get the sheet using the ID. Keep in mind that this is an older workspace, so there might be better methods to connect.
For my use case, I fragmented the columns, rows, and cells, then used a FeatureMerger to merge on column ID. Your use case might be different.
Fragment Columns Query: json["columns"][*]
Fragment Rows Query: json["rows"][*]
Fragment Cells Query (row_cells): json[*]
I used prefixes in the JSONFragmenters to help identify them easier with col_, row_, and cell_. I then merged on cell_columnId and col_id.
Each feature represents a cell with the attributes of the cell, row, and column.
In this way, if you need to manipulate them, you can use a JSONTemplater to create your payload to update the rows with the modified cell values. I’m using the GroupCounter and the ListBuilder to ensure each feature contains the maximum number of updates per API call that it allows.
Here are the settings for the JSONTemplater to give you an idea of how I did it:
JSONTemplater [JSONTemplater] Group Processing: Group Sub-Features By: row_id Grouped Sub-Features are Consecutive: No Template Expression: { "id": fme:get-attribute("row_id"), "cells": [ fme:process-features("SUB") ] ... Template File: <not set> Validation: Validate Attribute/Template Names: Yes Output Attribute Name: Result: json_payload SUB Template Expression: { "columnId": fme:get-attribute("col_id"), "value": fme:get-attribute("new_cell_value"), "strict": false } ...
This workflow might not be the most efficient, but hopefully it helps.