ID为#的用户在配置文件ID上没有正确的视图

时间:2016-12-01 11:03:26

标签: podio

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

用户是工作区管理员,我添加的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

2 个答案:

答案 0 :(得分:1)

使用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)

答案 1 :(得分:1)

我发现php或podio的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接受。现在代码运行正常。