dilame / instagram-private-api

NodeJS Instagram private API SDK. Written in TypeScript.
MIT License
5.86k stars 1.13k forks source link

Posting story results in 400 Bad request #1569

Open maxbauer opened 2 years ago

maxbauer commented 2 years ago

Bug Report

I was trying to upload an image into the story of my account. Login works as expected but when uploading the image into the story or as an album I'm getting a 400 error. Is anything known regarding this error?

Requirements

Code

 await ig.publish.album(albumContent).catch(err => console.error(err)); // also throws the error below

...
  const fileToUpload = readFileSync(path);
        await ig.publish.story({
            file: fileToUpload
        }).catch(err => console.error(err)); // results in error below

Error and Output

IgResponseError: POST /rupload_igphoto/123....789_0_123...456 - 400 Bad Request; 
    at Request.handleResponseError (/Users/project/node_modules/instagram-private-api/src/core/request.ts:172:12)
kingbotss commented 2 years ago

That means IG changed its API. #1573 , #1574 #1575 , #1567

NickCis commented 2 years ago

@maxbauer I had a similar issue posting a video:

IgResponseError: POST /rupload_igphoto/165.....3885_0_766....37 - 400 Bad Request; 
    at Request.handleResponseError (/root/sandbox/tws-ig-live/node_modules/instagram-private-api/src/core/request.ts:172:12)
    at Request.send (/root/sandbox/tws-ig-live/node_modules/instagram-private-api/src/core/request.ts:83:24)
    at UploadRepository.photo (/root/sandbox/tws-ig-live/node_modules/instagram-private-api/src/repositories/upload.repository.ts:23:22)
    at PublishService.video (/root/sandbox/tws-ig-live/node_modules/instagram-private-api/src/services/publish.service.ts:167:5)

And the problem was that I was using a png cover image, with a jpg one worked correctly. If I'm not mistaken the lib is hardcoding a jpg moz image format. What image format are you using?

Nerixyz commented 2 years ago

And the problem was that I was using a png cover image, with a jpg one worked correctly.

Docs don't mention this but only jpeg is accepted.

If I'm not mistaken the lib is hardcoding a jpg moz image format.

This just says, the image was compressed with mozjpeg which the android app uses.