id 为 # 的用户在 id 为 # 的个人资料上没有正确的视图

The user with id # does not have the right view on profile with id #

我正在尝试将联系人添加到联系人字段,该字段目前在应用程序中没有任何信息。我最初尝试通过应用程序身份验证进行此操作,但发现此 post on Podio forum and this 并将身份验证更改为用户。

用户是工作区管理员,我添加的profile_id是工作区成员,应用没有限制。

我错过了什么,我该如何解决这个问题?

$item_id = 1111111;
$field_id = 2222222;
$profile_id = 3333333;

Podio::authenticate_with_password( 'admin_user_email', 'password' );
$item = PodioItem::get_basic( $item_id );
$external_id = 'sign-off-authority';
$contact = new PodioContactItemField( array( 'field_id' => $field_id, 'external_id' => $external_id, 'values' => array( 'profile_id' => $profile_id ) ) );
$item->fields[] = $contact;
$item->save();

产生以下堆栈跟踪:

Fatal error: 
Uncaught PodioForbiddenError: 
"The user with id #### does not have the right view on profile with id ####" 
Request URL: http://api.podio.com/item/1111111 Stack Trace: 
#0 C:\xampp\htdocs\podio-api\lib\Podio.php(322): Podio::request('PUT', '/item/1111111', Array) 
#1 C:\xampp\htdocs\podio-api\models\PodioItem.php(184): Podio::put('/item/1111111', Array) 
#2 C:\xampp\htdocs\podio-api\models\PodioItem.php(67): PodioItem::update(1111111, Array, Array) 
#3 C:\xampp\htdocs\getItems.php(48): PodioItem->save() 
#4 {main} thrown in C:\xampp\htdocs\podio-api\lib\Podio.php on line 286

我使用 user_id 而不是 profile_id 对我有用。可以试试吗?

这是 ruby 中的工作示例:

Podio.client.authenticate_with_credentials(<user_email>, <user_password>)
field_external_id = 'requester'
field_new_value = [{'value' => {'type' => 'user', 'id' => <some_other_user_id>}}, 
                   {'value' => {'type' => 'user', 'id' => <different_user_id>}}]
Podio::ItemField.update(item_id, field_external_id, field_new_value)

我发现 php 或跑道的 php api 库正在将我存储的值转换为数组,而不是将其保留为整数值。我尝试同时使用 user_id 和 profile_id 两者都不起作用,直到我通过输出日志意识到发生了什么。我必须将代码更新为:

$profile_id = 3333333;
$arr = [];
$arr['profile_id'] = $profile_id;
$contact = new PodioContactItemField( array( 'field_id' => $field_id, 'external_id' => $external_id, 'values' => $arr ) );

通过创建数组并将其添加到对象,它保留了预设格式并被 api 接受。现在代码运行正常。