IsraelOrtuno / pipedrive

Complete Pipedrive API client for PHP
MIT License
166 stars 58 forks source link

File upload #3

Closed stephanvierkant closed 8 years ago

stephanvierkant commented 8 years ago

I can't get the file upload working. I'm not sure it's an issue with the library, maybe I'm doing something wrong. If so, I'm sorry ;)

public function uploadFile($dealId, \SplFileInfo $file)
{
     $upload = $this->pipedrive->files->add([
        'file' => $file,
        'deal_id' => $dealId
    ]);
}

This throws a PipedriveException: 'No files were provided with the request.'.

What's going wrong?

IsraelOrtuno commented 8 years ago

Let me have a look...

IsraelOrtuno commented 8 years ago

I am getting this error You need to be authorized to make this request, looks like it's a Pipedrive Error. Have just notified them, will get back to you.

IsraelOrtuno commented 8 years ago

Commit e8800a419afc0fe26fd3b2a4403a4120b2307082 should fix the issue, have to apologise, I did not implement this part. I have been playing and it should work...

Have just tagged 0.3.0, so update to that version and:

$file = new \SplFileInfo('file.jpg');

$pipedrive->files->add([
    'file'   => $file,
    'person_id' => 1
]);

Will include this into the docs soon.

Let me know if everything was ok.

stephanvierkant commented 8 years ago

It's not working for me, unfortunately. I'm getting a 400 error from Pipedrive.

Info from Response: content.error: An error occurred while saving the file. content.error_info: Please check developers.pipedrive.com for more information about Pipedrive API. content.data.error_code: unknown_error

IsraelOrtuno commented 8 years ago

What kind of file are you trying to save? I got that error when saving a .php file, but it was obvious.

IsraelOrtuno commented 8 years ago

Have just checked, I've got that error when uploading a .md file. However I have no problem uploading a .jpg file...

stephanvierkant commented 8 years ago

Even with PDF and JPG it's not working for me.

IsraelOrtuno commented 8 years ago

Could you email me one of those files to ai.ortuno at gmail.com?

stephanvierkant commented 8 years ago

Thanks, this time it was my fault. Thanks for helping!