Ok, here's my issue. Please forgive me if this has been asked somewhere. I did a search on the site and couldn't find what I'm looking for. I am very, very, very new to Workfront, and their documentation seems rather limited with regard to what I'm looking to do.
I know how to get the query from my database and convert it to JSON.
I can log into Workfront and create a custom form. I can add a drop down list to it.
What I need to do is get the JSON into the drop down list on the page. So I don't even know if popt is the right API to use.
I get that I need to probably use
/attask/api/v7.0/popt?method=post&updates=[{json obj 1}, {json obj 2}]
but I don't know how to associate it with the correct drop down.
If someone could please point me in the right direction, I would be very grateful.
Per Brian's request below:
Is there a way to "bulk add"? And can you explain the parameters? Is $option the string that will show in the drop-down? What about and the label value? How can I find the ID of the drop-down list?
EDITED TO ADD
Thanks to @Brian R for all his help.
I am wondering if there's a limit to the number of selections in the drop-down list. My list is going to have over a thousand "rows", so I will need it to be able to have over a thousand entries.
Also, is there a way to "bulk insert", passing multiple JSON elements to the api all at once?
And it looks like I should use PUT instead of POST for saving new data, but how would I get rid of old data?
I'm surprised popt is a tag...
So to be clear, you're not wanting to create new options in the drop down (it's a finite size with fixed contents) but you do want to assign values to each item, so if someone selects option 'bob' as a human-readable choice, it would be assigned a JSON object that you have generated. Is that right?
In that case, you'll need to update each popt individually. So you'll first need to get a list of every option in the dropdown list, through a call like:
GET https://<url>.my.workfront.com/attask/api/v7.0/PARAM/<ID of the parameter(dropdown list)>?fields=parameterOptions&apiKey=<key>
Then, you'll iterate through each result.parameterOptions and set the value:
foreach($option in $result.parameterOptions){
{
PUT https://<url>.my.workfront.com/attask/api/v7.0/POPT/<$option>?value=<json value>&label=<human readable choice>&apiKey=<key>
}
To address your response below wherein the parameter is blank (dropdown list with null value), you simply need to create the popts on your own. You'll first need to identify how to extract the data from your JSON object, as you'll have at least one and no more than two entries per drop-down choice (a human-readable selection, which is mandatory, and an optional value assigned to said choice).
foreach $element in $JSON
{
$label = <extract label from $element>
[$value = <optional, extract value from $element>]
POST https://<url>.my.workfront.com/attask/api/v7.0/POPT?<label=$label>[<&value=$value>]¶meterID=<ID of dropdown list>&apiKey=<key>
}