Parsing Multi Picklist through API
Hi everyone,
I just started working with the SmartSheet API. So far, everything has been straightforward, except one thing; I am trying to submit new rows to a sheet but can't seem to get the value of the Multi Picklist right. If submitted as a string in various formats, the value only displays as one long tag including all selected values in the Dashboard. I experimented with different separators, parsing modes, and JSON structures but to no avail. I would like to display values as separate tags.
Could anyone point in the right direction?
Thanks!
Max
Best Answer
-
Hi @maxibenner, can you show us what your code looks like right now?
In your example screenshot, it looks like you're trying to pass in 3 values, as an array, which is correct. However, Smartsheet is interpreting the array as a string.
For example, this would be incorrect:
"objectValue": {
"objectType": "MULTI_PICKLIST",
"values": "["Option A", "Option C"]"
}Whereas this would be correct:
"objectValue": { "objectType": "MULTI_PICKLIST", "values": ["Option A", "Option C"] }
The first one has an extra set of parenthesis around the array, which is incorrect because Smartsheet will interpret the whole thing as a JSON string.
The second one is correct because Smartsheet will interpret it as a JSON string array.
Best!
Nathan Braun (Founder of SSFeatures) (nathan@ssfeatures.com) (LinkedIn)
SSFeatures makes Smartsheet way easier to use and it saves you hours of work every week. It adds essential features into Smartsheet to save you time. For example: — Auto Sorting — Sorting with Filters — Report PDF Generation — Copy and Paste Conditional Formats — Copy and Paste Automation Workflows — Column Manager — and so many more.
Answers
-
Hi @maxibenner, can you show us what your code looks like right now?
In your example screenshot, it looks like you're trying to pass in 3 values, as an array, which is correct. However, Smartsheet is interpreting the array as a string.
For example, this would be incorrect:
"objectValue": {
"objectType": "MULTI_PICKLIST",
"values": "["Option A", "Option C"]"
}Whereas this would be correct:
"objectValue": { "objectType": "MULTI_PICKLIST", "values": ["Option A", "Option C"] }
The first one has an extra set of parenthesis around the array, which is incorrect because Smartsheet will interpret the whole thing as a JSON string.
The second one is correct because Smartsheet will interpret it as a JSON string array.
Best!
Nathan Braun (Founder of SSFeatures) (nathan@ssfeatures.com) (LinkedIn)
SSFeatures makes Smartsheet way easier to use and it saves you hours of work every week. It adds essential features into Smartsheet to save you time. For example: — Auto Sorting — Sorting with Filters — Report PDF Generation — Copy and Paste Conditional Formats — Copy and Paste Automation Workflows — Column Manager — and so many more.
-
Hi @SSFeatures,
Thank you for your quick response! You are correct in that I was using the JSON string version which did not parse as expected. Previously, rows did get added to the sheet, even though of course not properly formatted in the case of multi-picklists. I just updated my code to reflect your suggestion. However, now I am receiving Smartsheet error 400: Unable to parse request. This is the payload I am sending:[ { "toBottom": true, "cells": [ { "columnId": 2521781166100356, "value": "test" }, { "columnId": 5151869351186308, "value": "test" }, { "columnId": 564034677723012, "value": "test@test.com" }, { "columnId": 5630584258514820, "value": "scientific or research organization" }, { "columnId": 3754029496356740, "value": "test" }, { "columnId": 7156563120443268, "value": "Central and Southern Asia" }, { "columnId": 7882384072200068, "value": "Education" }, { "columnId": 6604560636006276, "value": "test" }, { "columnId": 2267047796625284, "value": [ "Early Career Explorers", "Livestreams", "Education Portal" ], "objectType": "MULTI_PICKLIST" }, { "columnId": 1791193270407044, "value": "test" } ] } ]
Does anything stick out to you?
Best,
Max -
@SSFeatures Oh my, I just realized that I needed to nest the values under the
objectValue
key. Your examples gave me the hint. Thank you very much for your help! -
@maxibenner I'm glad you figured it out! You're super welcome!
Nathan Braun (Founder of SSFeatures) (nathan@ssfeatures.com) (LinkedIn)
SSFeatures makes Smartsheet way easier to use and it saves you hours of work every week. It adds essential features into Smartsheet to save you time. For example: — Auto Sorting — Sorting with Filters — Report PDF Generation — Copy and Paste Conditional Formats — Copy and Paste Automation Workflows — Column Manager — and so many more.