Asana上传错误与Asana / php-asana

时间:2016-02-27 02:55:37

标签: php asana asana-api

尝试测试提供的示例代码:

$attachment = $client->attachments->createOnTask(
                $enquiry->id,
                'hello word',
                'upload.txt',
                'text/plain'
            );

错误: 400 File is not an object

客户端绝对有效(能够在之前创建任务)。 taskId($enquiry->id)是正确的(通过转到url等进行检查)。

使用库的v0.4.0和PHP 5.6.18-1关闭Homestead虚拟机。

关于SO的类似问题谈论编码错误但在我的情况下一切似乎都没问题。

以下是回复:

class Httpful\Response#961 (13) {
  public $body =>
  class stdClass#964 (1) {
    public $errors =>
    array(1) {
      [0] =>
      class stdClass#973 (2) {
        ...
      }
    }
  }
  public $raw_body =>
  string(219) "{"errors":[{"message":"file: File is not an object","help":"For more information on API status codes and how to handle them, read the docs on errors: https://asana.com/developers/documentation/getting-started/errors"}]}"
  public $headers =>
  class Httpful\Response\Headers#963 (1) {
    private $headers =>
    array(11) {
      'server' =>
      string(5) "nginx"
      'date' =>
      string(29) "Sat, 27 Feb 2016 02:36:49 GMT"
      'content-type' =>
      string(31) "application/json; charset=UTF-8"
      'transfer-encoding' =>
      string(7) "chunked"
      'connection' =>
      string(10) "keep-alive"
      'x-asana-content-string-length' =>
      string(3) "219"
      'pragma' =>
      string(8) "no-cache"
      'set-cookie' =>
      string(22) "TooBusyRedirectCount=0"
      'cache-control' =>
      string(8) "no-store"
      'x-asana-preferred-release-revision' =>
      string(56) "20160226_220201_ce3e88b3589d50e067532bbd0e824a44148e6738"
      'x-robots-tag' =>
      string(4) "none"
    }
  }
  public $raw_headers =>
  string(404) "HTTP/1.1 400 Bad Request
Server: nginx
Date: Sat, 27 Feb 2016 02:36:49 GMT
Content-Type: application/json; charset=UTF-8
Transfer-Encoding: chunked
Connection: keep-alive
X-Asana-Content-String-Length: 219
Pragma: no-cache
Set-Cookie: TooBusyRedirectCount=0
Cache-Control: no-store
X-Asana-Preferred-Release-Revision: 20160226_220201_ce3e88b3589d50e067532bbd0e824a44148e6738
X-Robots-Tag: none"
  public $request =>
  class Httpful\Request#962 (22) {
    public $uri =>
    string(62) "https://app.asana.com/api/1.0/tasks/(task_id)/attachments"
    public $method =>
    string(4) "POST"
    public $headers =>
    array(2) {
      'X-Asana-Client-Lib' =>
      string(118) "version=0.4.0&language=PHP&language_version=5.6.18-1%2Bdeb.sury.org%7Etrusty%2B1&os=Linux&os_version=3.19.0-25-generic"
      'Authorization' =>
      string(41) "Bearer (valid bearer)"
    }
    public $raw_headers =>
    string(487) "POST /api/1.0/tasks/(task_id)/attachments HTTP/1.1
Host: app.asana.com
Expect:
User-Agent: Httpful/0.2.20 (cURL/7.35.0 PHP/5.6.18-1+deb.sury.org~trusty+1 (Linux))
Content-Type: multipart/form-data
Accept: */*; q=0.5, text/plain; q=0.8, text/html;level=3;q=0.9, application/json
X-Asana-Client-Lib: version=0.4.0&language=PHP&language_version=5.6.18-1%2Bdeb.sury.org%7Etrusty%2B1&os=Linux&os_version=3.19.0-25-generic
Authorization: Bearer 0/88eebe64d4af7bd966936bbe346be679
"
    public $strict_ssl =>
    bool(false)
    public $content_type =>
    string(19) "multipart/form-data"
    public $expected_type =>
    string(16) "application/json"
    public $additional_curl_opts =>
    array(0) {
    }
    public $auto_parse =>
    bool(true)
    public $serialize_payload_method =>
    int(0)
    public $username =>
    NULL
    public $password =>
    NULL
    public $serialized_payload =>
    array(1) {
      'file' =>
      string(48) "@/tmp/YCRYJd;filename=upload.txt;type=text/plain"
    }
    public $payload =>
    array(1) {
      'file' =>
      string(48) "@/tmp/YCRYJd;filename=upload.txt;type=text/plain"
    }
    public $parse_callback =>
    NULL
    public $error_callback =>
    NULL
    public $send_callback =>
    NULL
    public $follow_redirects =>
    bool(false)
    public $max_redirects =>
    int(25)
    public $payload_serializers =>
    array(0) {
    }
    public $_ch =>
    resource(652) of type (Unknown)
    public $_debug =>
    NULL
  }
  public $code =>
  int(400)
  public $content_type =>
  string(16) "application/json"
  public $parent_type =>
  string(16) "application/json"
  public $charset =>
  string(5) "UTF-8"
  public $meta_data =>
  array(26) {
    'url' =>
    string(62) "https://app.asana.com/api/1.0/tasks/(task_id)/attachments"
    'content_type' =>
    string(31) "application/json; charset=UTF-8"
    'http_code' =>
    int(400)
    'header_size' =>
    int(408)
    'request_size' =>
    int(552)
    'filetime' =>
    int(-1)
    'ssl_verify_result' =>
    int(0)
    'redirect_count' =>
    int(0)
    'total_time' =>
    double(3.435421)
    'namelookup_time' =>
    double(2.1E-5)
    'connect_time' =>
    double(0.29363)
    'pretransfer_time' =>
    double(2.023479)
    'size_upload' =>
    double(187)
    'size_download' =>
    double(219)
    'speed_download' =>
    double(63)
    'speed_upload' =>
    double(54)
    'download_content_length' =>
    double(-1)
    'upload_content_length' =>
    double(187)
    'starttransfer_time' =>
    double(2.023485)
    'redirect_time' =>
    double(0)
    'redirect_url' =>
    string(0) ""
    'primary_ip' =>
    string(12) "52.70.61.144"
    'certinfo' =>
    array(0) {
    }
    'primary_port' =>
    int(443)
    'local_ip' =>
    string(9) "10.0.2.15"
    'local_port' =>
    int(49537)
  }
  public $is_mime_vendor_specific =>
  bool(false)
  public $is_mime_personal =>
  bool(false)
  private $parsers =>
  NULL
}


[Asana\Errors\InvalidRequestError]  
Invalid Request 

1 个答案:

答案 0 :(得分:1)

查看它和Asana / php-asana uploadFile代码与php 5.6 +不兼容。

拉取请求:here