S
S
SimBioT192017-03-22 14:52:52
PHP
SimBioT19, 2017-03-22 14:52:52

Why doesn't the docs.save Vk api method work?

I upload a file (document) to the Vkontakte server, then send them the file parameter , but I constantly get an error with code 100:

One of the parameters specified was missing or invalid: file field is invalid

Although I do not do anything with this parameter.
...

  if ($curl_error_code > 0) {
         return ['status' => 'error', 'text' => $curl_error_desc . ' (' . $curl_error_code . '); HTTP-код: ' . $curl_info];
  }

 $file_response = json_decode($curl_result, TRUE); // Получаю параметр file

// отправляю его
$response = $vk->api('docs.save',
                [
                    'access_token' => $group->access_token,
                    'file' => $file_response ['file']
                ]
            );

if (isset($response['error'])) { // Всегда ошибка, указанная выше

die(var_dump($respose));

}

With error, my file parameter is returned, which if pasted into the example here https://vk.com/dev/docs.save
will work.
So why might the error occur?
array(1) {
  ["error"]=>
  array(3) {
    ["error_code"]=>
    int(100)
    ["error_msg"]=>
    string(77) "One of the parameters specified was missing or invalid: file field is invalid"
    ["request_params"]=>
    array(4) {
      [0]=>
      array(2) {
        ["key"]=>
        string(5) "oauth"
        ["value"]=>
        string(1) "1"
      }
      [1]=>
      array(2) {
        ["key"]=>
        string(6) "method"
        ["value"]=>
        string(14) "docs.save.json"
      }
      [2]=>
      array(2) {
        ["key"]=>
        string(4) "file"
        ["value"]=>
        string(185) "205947707|86926188|-1|810538|d03df3de35|gif|251463|giphy.gif|61d36032d1452ac341f633061bb60c4e|4d47ff4fd604b035f4bb6a1183a5a897|m_d03df3de35|16|m:130x98,s:100x75,x:604x453,o:480x360|W10="
      }
      [3]=>
      array(2) {
        ["key"]=>
        string(1) "v"
        ["value"]=>
        string(4) "5.62"
      }
    }
  }
}

Answer the question

In order to leave comments, you need to log in

2 answer(s)
T
Tom Nolane, 2017-03-22
@SimBioT19

I upload like this (although not in php , but in c# , but the essence is the same):
1) I get a server for uploading:
I parse the response and get the url where to upload
2) I upload the file to the specified url (using a regular POST request), I get the json response and take the file
from there 3) I save it and get it as an attachment :

string request_path = "https://api.vk.com/method/docs.save?file="+file+"&title=999999999&tags=9999999999&v="+Vk.Version+"&access_token=" + Vk.AccessToken;
            
var json = JObject.Parse(VkRequest(request_path)); // в json - уже мой attachment, который использую при отправке на стену

ps
Accepted formats: any formats except for mp3 and executable files.
Restrictions: a file of no more than 200 MB.
POST request field: file.

T
temamagic, 2017-03-28
@temamagic

Bug from vk. Tech support response:yeDiBBM.png

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question