Comments (4)
I've tried adding the implementation and when I do :
$params = array('file' => $my_zip_file_local_path);
try
{
$my_client->apps()->upload($params);
}
else
{
die('<pre>' . print_r($my_client()->getDebug(), true) . '</pre>');
}
I get this :
Zendesk\API\Debug Object
(
[lastRequestHeaders] => POST /api/v2/apps/uploads.json HTTP/1.1
Authorization: Basic cnlhbkBlLW1vbnNpdGUuY29tL3Rva2VuOk9uRnlSd1YwM2tSYTdmWVljWmJoQ0Q0VWVUZk1UVTV1SVFsY1k5eGs=
Host: testemonsite.zendesk.com
Accept: application/json
Content-Length: 83319
Expect: 100-continue
Content-Type: application/binary; boundary=----------------------------b9438b9d3355
[lastResponseCode] => 422
[lastResponseHeaders] => HTTP/1.1 100 Continue
HTTP/1.1 422 Unprocessable Entity
Server: nginx/1.4.7
Date: Thu, 22 May 2014 14:01:25 GMT
Content-Type: application/json; charset=utf-8
Transfer-Encoding: chunked
Connection: keep-alive
Status: 422 Unprocessable Entity
X-FRAME-OPTIONS: SAMEORIGIN
X-XSS-Protection: 1; mode=block
Set-Cookie: _zendesk_shared_session=eyJpZCI6IjQ1OGM2ZTY0M2EwODk3YWFlNDQ3Y2ZjODFhOWY2NTgyIiwiYWNjb3VudCI6NTI1MDI1fQ%3D%3D--7d74591285df788fb00663808acceeab8b958861; path=/; secure; HttpOnly
Set-Cookie: _carson_container_session=BAh7B0kiD3Nlc3Npb25faWQGOgZFVEkiJTM1NTRkNGE3MmUwNWI5NmNlMzUwOTU2NmJhYzRhMTI4BjsAVEkiDGFjY291bnQGOwBGaQPhAgg%3D--102f4a3a163edd56ca3fd8f88fa579e86b9b557c; path=/; secure; HttpOnly
X-Zendesk-Origin-Server: carson3.pod3.dub1.zdsys.com
X-UA-Compatible: IE=Edge,chrome=1
Cache-Control: no-cache
X-Zendesk-Request-Id: 767875d6d4316645beaf8bd0ac814a48
X-Request-Id: 767875d6d4316645beaf8bd0ac814a48
X-Runtime: 1.063949
X-Rack-Cache: invalidate, pass
)
But maybe i'm using this part of the API not properly at all....
from zendesk_api_client_php.
After trying to execute the request directly with CURL, like this :
$ch = curl_init();
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_MAXREDIRS, 10);
curl_setopt($ch, CURLOPT_URL, 'https://mysubdomain.zendesk.com/api/v2/apps/uploads.json');
curl_setopt($ch, CURLOPT_USERPWD, $user . '/token:' . $token));
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-type: application/binary'));
curl_setopt($ch, CURLOPT_POST, true);
$file = fopen($filepath, 'r');
$size = filesize($filepath);
$filedata = fread($file, $size);
curl_setopt($ch, CURLOPT_POSTFIELDS, $filedata);
curl_setopt($ch, CURLOPT_INFILE, $file);
curl_setopt($ch, CURLOPT_INFILESIZE, $size);
curl_setopt($ch, CURLOPT_USERAGENT, "MozillaXYZ/1.0");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
$output = curl_exec($ch);
curl_close($ch);
$decoded = json_decode($output);
die('<pre>' . print_r($decoded, true) . '</pre>');
I get this :
stdClass Object
(
[error] => RecordInvalid
[description] => Attachment cannot be empty
Attachment file name cannot be empty
)
Also, after analyzing the Http.php code, i think there's a problem with the param
array('uploaded_data' => '@'.$params['file'])
in Apps.php passed as $json in Http.code wich there's nothing converting the 'uploaded_data' param in "file post". This variable should be nammed $json['filename'] think.
In Http.php :
if($method == 'POST') {
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $json);
if(isset($json['filename'])) {
$file = fopen($json['filename'], 'r');
$size = filesize($json['filename']);
$filedata = fread($file, $size);
curl_setopt($curl, CURLOPT_POSTFIELDS, $filedata);
curl_setopt($curl, CURLOPT_INFILE, $file);
curl_setopt($curl, CURLOPT_INFILESIZE, $size);
curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-type: application/binary'));
}
}
from zendesk_api_client_php.
Looks like PR #26 fixed this issue. Closing.
from zendesk_api_client_php.
I don't believe #26 fixed this issue. See https://github.com/zendesk/zendesk_api_client_php/blob/master/src/Zendesk/API/Apps.php#L40 as @RyanGilles mentioned.
from zendesk_api_client_php.
Related Issues (20)
- PHP8 Error: array_merge() does not accept unknown named parameters HOT 1
- php 5.6 Parse error: syntax error, unexpected '?', expecting variable (T_VARIABLE) in /var/www/clients/client1/web6/web/vendor/guzzlehttp/guzzle/src/HandlerStack.php on line 47 HOT 1
- Update Packagist with the new version HOT 3
- Unmerged PRs HOT 3
- Okta HOT 2
- Oktane22
- Add comment to ticket HOT 3
- FindAll method Ambiguity in Error Webhooks HOT 3
- No events API support? HOT 2
- Type error: Argument 1 passed to GuzzleHttp\Client::send()
- Allow any PSR-17 and PSR-18 implementation to be used
- How to get the latest tickets created by a customer? HOT 2
- webhook count support not available ? HOT 1
- Repository maintenance status HOT 14
- Problem with updates of users HOT 2
- tickets createMany method implementation HOT 2
- No method called iterator available in Zendesk\API\Resources\Core\Tickets HOT 2
- Testing Slack notification HOT 3
- Test Issue HOT 3
- Another test HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from zendesk_api_client_php.