nediam / phraseapp-lib

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to use upload.create command?

prolic opened this issue · comments

I tried several things:

$response = $this->client->request('upload.create', [
     'project_id' => $this->projectId,
     'locale_id' => $localeId,
     'file' => $data, // xml string
     'file_format' => 'symfony_xliff',
     'tags' => $domain
]);

as well as:

$response = $this->client->request('upload.create', [
     'project_id' => $this->projectId,
     'locale_id' => $localeId,
     'file' => $fileName, // file name on disk
     'file_format' => 'symfony_xliff',
     'tags' => $domain
]);

and:

$response = $this->client->request('upload.create', [
     'project_id' => $this->projectId,
     'locale_id' => $localeId,
     'file' => '@' . $fileName, // file name on disk
     'file_format' => 'symfony_xliff',
     'tags' => $domain
]);

But I always receive the response:

Error executing command: Client error response [url] https://api.phraseapp.com/api/v2/projects/<my project id>/uploads [status code] 422 [reason phrase] status code 422

While doing it from linx with curl:

curl -u <my api key>: "https://api.phraseapp.com/api/v2/projects/<my project id>/uploads" -X POST -F file=@/tmp/booking_en.xlf -F file_format=symfony_xliff -F tags=booking -F locale_id=<my locale id>

works just fine, what am I doing wrong? Any help is greatly appreciated!