【问题标题】:Error 1030 when I try to modify a Smartsheet尝试修改 Smartsheet 时出现错误 1030
【发布时间】:2015-08-21 02:08:26
【问题描述】:

我有一个 php 页面,其中列出了不同用户的 smartsheet 内容。 它使用工作名称、开始日期和交货日期等信息填充表格。但我也希望用户能够在工作完成后勾选一个复选框。

当复选框被选中时,另一个(非常基本的)页面被调用以将新值存储到智能表中。

这个页面是由一个基本的 get 命令触发的:

http://myurl/index.php?colId=XXX&rowId=YYY&status=checked

使用的变量在哪里:

colId=The ID of the column to be changed
rowId=The ID of the row to be changed
checked=If the checkbox is checked
status=The value stored in the smartheet 
       (1 for a checked checkbox and '' for an unchecked checkbox)

这是index.php的代码(盗自this post):

$inputToken = "myInputToken";
$colId=$_GET['colId'];
$rowId=$_GET['rowId'];
if($_GET['status'] == "checked"){
               $status='1';
               }
else{
               $status='';
}
$ch = curl_init("https://api.smartsheet.com/1.1/row/".$rowId./cells");
$header = array("Authorization: Bearer ".$inputToken,
        "Content-Type: application/json",
        "Assume-User: myName%40myDomainName");
$fields =  '[{"columnId": $colId, "value": "'.$status.'", "displayValue": "'.$status.'"}]';
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_POSTFIELDS,  $fields);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
$result = curl_exec($ch);
print_r($result);

“输入令牌”由与“假定用户”电子邮件相同的电子邮件生成。 当我登录时,我可以更改常规智能表中的值。 但是当我运行网页时仍然出现此错误:

{"errorCode":1030,"message":"You are unable to assume the user specified."}

有谁知道我做错了什么?

任何帮助将不胜感激!

【问题讨论】:

  • $inputToken 需要是由管理员帐户生成的令牌。然后Assume-User 是您要登录的电子邮件地址。你是这样做的吗?如果您可以访问所有帐户,您还可以为每个帐户生成一个 $inputToken 并删除 Assume-User 行。
  • 感谢您的回复!不幸的是,我目前无法访问管理员帐户。但是明天我的同事回来时我会试一试。我会及时通知你的!
  • 听起来这是一个问题,因为假设用户是为管理员帐户准备的。我会发表我的评论作为答案。
  • 我只想说它与管理员用户的令牌一起工作。非常感谢您的宝贵帮助!

标签: php smartsheet-api smartsheet-api-1.1


【解决方案1】:

有两种方法可以作为用户登录。首先,您可以使用该用户帐户的令牌直接登录。标题看起来像:

$header = array('Authorization: Bearer '.$userToken,
    "Content-Type: application/json");

第二种选择是使用管理员帐户以其他用户身份登录。为此,您可以使用假设用户标头和管理员令牌。标题看起来像:

$header = array('Authorization: Bearer '.$adminToken,
    'Content-Type: application/json',
    'Assume-User: someUser%40someDomain.com');

假设用户的文档可以在here找到。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-04-01
    • 1970-01-01
    • 2011-09-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-01-18
    • 1970-01-01
    相关资源
    最近更新 更多