Workfront和Popt API [英] Workfront and the popt API

查看:131
本文介绍了Workfront和Popt API的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好,这是我的问题.如果有人问过这个问题,请原谅我.我在该网站上进行了搜索,但是找不到我想要的东西.我对Workfront非常非常陌生,关于我要做什么,他们的文档似乎非常有限.

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.

我知道如何从数据库中获取查询并将其转换为JSON.

I know how to get the query from my database and convert it to JSON.

我可以登录Workfront并创建一个自定义表单.我可以在其中添加一个下拉列表.

I can log into Workfront and create a custom form. I can add a drop down list to it.

我需要做的是将JSON放入页面的下拉列表中.因此,我什至不知道popt是否适合使用正确的API.

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.

我知道我可能需要使用

/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.

根据以下Brian的要求:

Per Brian's request below:

是否有一种批量添加"的方法?您能解释一下这些参数吗? $ option是在下拉列表中显示的字符串吗?那标签的价值又如何呢?如何找到下拉列表的ID?

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?

已编辑添加

感谢@Brian R的所有帮助.

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.

还有,有没有一种方法可以批量插入",一次将多个JSON元素全部传递给api?

Also, is there a way to "bulk insert", passing multiple JSON elements to the api all at once?

看起来我应该使用PUT而不是POST来保存数据,但是如何摆脱 数据?

And it looks like I should use PUT instead of POST for saving new data, but how would I get rid of old data?

推荐答案

我很惊讶popt是一个标签...

I'm surprised popt is a tag...

因此要清楚一点,您不想在下拉列表中创建新选项(它是具有固定内容的有限大小),但是您确实想为每个项目分配值,因此如果有人选择选项"bob"作为一个人类可读的选择,它将被分配一个您生成的JSON对象.是吗?

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>

然后,您将遍历每个result.parameterOptions并设置值:

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>
}

要在下面回答您的响应,其中参数为空(具有空值的下拉列表),您只需要自己创建弹出框.首先,您需要确定如何从JSON对象提取数据,因为每个下拉选择项至少具有一个且最多两个条目(人类可读的选择,这是必需的,而可选的是分配给所述选择的值).

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

这篇关于Workfront和Popt API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆