简体   繁体   English

Workfront和Popt API

[英]Workfront and the popt API

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. 我对Workfront非常非常陌生,关于我要做什么,他们的文档似乎很有限。

I know how to get the query from my database and convert it to JSON. 我知道如何从数据库中获取查询并将其转换为JSON。

I can log into Workfront and create a custom form. 我可以登录到Workfront并创建一个自定义表单。 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. 我需要做的是将JSON放入页面的下拉列表中。 So I don't even know if popt is the right API to use. 所以我什至不知道popt是否是正确使用的API。

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: 根据以下Brian的要求:

Is there a way to "bulk add"? 有没有办法“批量添加”? And can you explain the parameters? 您能解释一下这些参数吗? Is $option the string that will show in the drop-down? $ option是下拉列表中显示的字符串吗? What about and the label value? 那标签的价值又如何呢? How can I find the ID of the drop-down list? 如何找到下拉列表的ID?

EDITED TO ADD 编辑添加

Thanks to @Brian R for all his help. 感谢@Brian R的所有帮助。

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? 另外,有没有一种方法可以“批量插入”,一次将多个JSON元素都传递给api?

And it looks like I should use PUT instead of POST for saving new data, but how would I get rid of old data? 看起来我应该使用PUT而不是POST来保存数据,但是如何摆脱数据呢?

I'm surprised popt is a tag... 我很惊讶popt是一个标签...

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. 请注意,您不希望在下拉列表中创建新选项(内容固定的有限大小),但希望为每个项目分配值,因此,如果有人选择选项“ bob”作为人工选项,可读的选择,将为其分配一个已生成的JSON对象。 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: 然后,您将遍历每个result.parameterOptions并设置值:

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). 首先,您需要确定如何从JSON对象提取数据,因为每个下拉选择项至少具有一个且最多两个条目(人类可读的选择,这是必需的,而可选的是分配给所述选择的值)。

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>]&parameterID=<ID of dropdown list>&apiKey=<key>
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM