0

在我们公司,我们创建了一个自定义Issues应用程序。除了在 Web 界面中使用这个应用程序之外,我们还希望能够通过 git commit hooks 自动更改问题的状态(新的、已确认的、测试的、已解决的……)。基础工作正常(即更改状态、添加注释等),但我们还希望将当前项目的责任更改为特定用户。在这种特殊情况下,如果这个项目是创建者。

我的第一次尝试如下:

var appid = 1234; var itemid = 1;
var item = podio.ItemService.GetItemByAppItemId(appid, itemid);
var update = new Item {ItemId = item.ItemId};

var creator = item.CreatedBy.Id;
var resp = update.Field<ContactItemField>("responsibility");
resp.ContactIds = new List<int>{creator.Value};

//change some other fields as well

podio.ItemService.UpdateItem(update);

这会引发“找不到对象”异常,因为resp.ContactIds其中一个不能设置UserIdProfileId.

然后我试图ProfileId通过

podio.ContactService.GetUserContactField(creator.Value, "profile_id");

但这也会引发异常“(此方法不允许作为应用程序进行身份验证”)。

那么,当我将身份验证用作应用程序时,如何为用户获取适当的配置文件 ID?

4

1 回答 1

1

好的,我找到了一种解决方法,不确定是否适用于其他情况,但它适用于当前情况。

我没有使用 C# 接口来设置ContactIdsContactItemField而是直接设置 json 值。

var appid = 1234; var itemid = 1;
var item = podio.ItemService.GetItemByAppItemId(appid, itemid);
var update = new Item {ItemId = item.ItemId};

var creator = item.CreatedBy.Id;
var resp = update.Field<ContactItemField>("responsibility");
resp.ContactIds = new List<int>(); // set to an empty list, so that resp.Values is initialized to an empty JArray

var u = new JObject { {"value", new JObject { {"type" , "user" }, {"id", creator } } } };
responsibleField.Values.Add(u); //add the new user to the Values of the field

//change some other fields as well
podio.ItemService.UpdateItem(update);

如果我设置valuewith 类型,user我可以使用 knownuserid并且服务器上的 API 负责查找。

于 2016-06-27T11:27:32.407 回答