U
U
UglePlastik2020-05-25 16:22:59
Node.js
UglePlastik, 2020-05-25 16:22:59

How to generate a correct POST request in NodeJS to the VK server?

Good afternoon, please tell me how the post-request should look like to send a photo to the VK server or what mistakes were made in mine? 5ecbc59bd8997485764470.png
So I decided to do it, I used the axios package for nodejs and the answer came with an empty photo field
I can’t figure out what the problem is ...

Code for possible edits, those who want to answer:

const photo = new FormData();
//photo.append('photo', request('https://cdn.dribbble.com/users/1192832/screenshots/4721535/dribbble.png'));
photo.append('photo', fs.createReadStream('./1.png'),{name: 'photo', filename: '1.png',  contentType: 'multipart/form-data'});


let axiosObj = {
  method: 'post',
  url: response_url,
  photo: photo,
  headers: photo.getHeaders()
}


  axios({
    method: axiosObj.method,
    url: 'https://pu.vk.com/c856028/upload.php?act=do_add&mid=202775171&aid=-14&gid=129045983&hash=f3feb8fac0be43d9b2cbb5e1f73cddd1&rhash=6a15f35314df64a037812b0ea9df5143&swfupload=1&api=1&wallphoto=1',
    photo: axiosObj.photo,
    headers: axiosObj.headers
  }).then(response =>{
    console.log(response)
  });

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
Pavel, 2020-05-25
@PavelFokeev

The method photos.getWallUploadServermust be called every time before uploading a photo. The link and hashes are tied to the IP of the requester, most likely. You are trying to upload a photo using a static link, most likely it has already lost its relevance.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question