instagram4j / instagram4j

:camera: Instagram private API in Java
Apache License 2.0
915 stars 276 forks source link

Upload video error "Handle is missing" #722

Open schuettec opened 2 months ago

schuettec commented 2 months ago

Pre-Checklist

I made sure...


Question

I tried uploading a video file to instagram with the following code

      OkHttpClient httpClient = IGUtils.defaultHttpClientBuilder()
          .build();
      IGClient client = IGClient.builder()
          .username(u)
          .password(p)
          .client(httpClient)
          .login();
      MediaConfigureToIgtvResponse response = client.actions()
          .igtv()
          .upload(videoFile, coverFile, title, caption)
          .get();

Pretty simple. The video file is uploaded in segments.

Here is a part of the logs showing the upload:

Mai 07, 2024 4:40:06 PM com.github.instagram4j.instagram4j.IGClient lambda$sendRequest$4
INFORMATION: Response for https://i.instagram.com/rupload_igvideo/... with body (truncated) : {"dc":"ldc2c05","offset":80000000}
Mai 07, 2024 4:40:06 PM com.github.instagram4j.instagram4j.actions.upload.UploadAction lambda$null$4
INFORMATION: ... Uploading segment (9/14)
Mai 07, 2024 4:40:06 PM com.github.instagram4j.instagram4j.IGClient sendRequest
INFORMATION: Sending request : https://i.instagram.com/rupload_igvideo/...?segmented=true&phase=transfer
Mai 07, 2024 4:40:09 PM com.github.instagram4j.instagram4j.IGClient$2 onResponse
INFORMATION: Response for https://i.instagram.com/rupload_igvideo/...?segmented=true&phase=transfer : 206
{"debug_info":{"retriable":true,"type":"PartialRequestError","message":"Partial request (did not match length of file)"}}

There is a PartialRequestError. Don't know if this is part of the problem, beause after the last segment it says:

Mai 07, 2024 4:40:21 PM com.github.instagram4j.instagram4j.IGClient lambda$sendRequest$4
INFORMATION: Response for https://i.instagram.com/rupload_igvideo/... with body (truncated) : {"dc":"ldc2c05","offset":130000000}
Mai 07, 2024 4:40:21 PM com.github.instagram4j.instagram4j.actions.upload.UploadAction lambda$null$4
INFORMATION: ... Uploading segment (14/14)
Mai 07, 2024 4:40:21 PM com.github.instagram4j.instagram4j.IGClient sendRequest
INFORMATION: Sending request : https://i.instagram.com/rupload_igvideo/...?segmented=true&phase=transfer
Mai 07, 2024 4:40:23 PM com.github.instagram4j.instagram4j.IGClient$2 onResponse
INFORMATION: Response for https://i.instagram.com/rupload_igvideo/...?segmented=true&phase=transfer : 200
{"media_id":18225969199273546,"status":"ok"}
Mai 07, 2024 4:40:23 PM com.github.instagram4j.instagram4j.IGClient lambda$sendRequest$4
INFORMATION: Response for https://i.instagram.com/rupload_igvideo/...?segmented=true&phase=transfer with body (truncated) : {"media_id":18225969199273546,"status":"ok"}
Mai 07, 2024 4:40:23 PM com.github.instagram4j.instagram4j.actions.upload.UploadAction lambda$null$3
INFORMATION: ... Done uploading segment 14
Mai 07, 2024 4:40:23 PM com.github.instagram4j.instagram4j.IGClient sendRequest
INFORMATION: Sending request : https://i.instagram.com/rupload_igvideo/...?segmented=true&phase=end
Mai 07, 2024 4:40:23 PM com.github.instagram4j.instagram4j.IGClient$2 onResponse
INFORMATION: Response for https://i.instagram.com/rupload_igvideo/...?segmented=true&phase=end : 200
{"status":"ok","xsharing_nonces":{}}

Seems fine for the video upload. But then it tries to upload the cover image and there is the ultimate error:

Mai 07, 2024 4:40:23 PM com.github.instagram4j.instagram4j.IGClient lambda$sendRequest$4
INFORMATION: Response for https://i.instagram.com/rupload_igvideo/...?segmented=true&phase=end with body (truncated) : {"status":"ok","xsharing_nonces":{}}
Mai 07, 2024 4:40:23 PM com.github.instagram4j.instagram4j.IGClient sendRequest
INFORMATION: Sending request : https://i.instagram.com/rupload_igphoto/..._0_...
Mai 07, 2024 4:40:24 PM com.github.instagram4j.instagram4j.IGClient$2 onResponse
INFORMATION: Response for https://i.instagram.com/rupload_igphoto/..._0_.... : 400
{"debug_info":{"retriable":false,"type":"ProcessingFailedError","message":"{\"message\":\"Handle is missing.\",\"status\":\"fail\"}"}}
Mai 07, 2024 4:40:24 PM com.github.instagram4j.instagram4j.IGClient lambda$sendRequest$4
INFORMATION: Response for https://i.instagram.com/rupload_igphoto/..._0_... with body (truncated) : {"debug_info":{"retriable":false,"type":"ProcessingFailedError","message":"{\"message\":\"Handle is 
Exception in thread "main" java.lang.RuntimeException: Posting a video to instagram failed.
Caused by: java.util.concurrent.ExecutionException: com.github.instagram4j.instagram4j.exceptions.IGResponseException
    at java.base/java.util.concurrent.CompletableFuture.reportGet(CompletableFuture.java:396)
    at java.base/java.util.concurrent.CompletableFuture.get(CompletableFuture.java:2073)
    at MyClass.main(MyClass.java:62)
Caused by: com.github.instagram4j.instagram4j.exceptions.IGResponseException
    at com.github.instagram4j.instagram4j.requests.IGRequest.parseResponse(IGRequest.java:72)
    at com.github.instagram4j.instagram4j.IGClient.lambda$sendRequest$4(IGClient.java:154)
    at java.base/java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:646)
    at java.base/java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:510)
    at java.base/java.util.concurrent.CompletableFuture.complete(CompletableFuture.java:2179)
    at com.github.instagram4j.instagram4j.IGClient$2.onResponse(IGClient.java:141)
    at okhttp3.internal.connection.RealCall$AsyncCall.run(RealCall.kt:504)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
    at java.base/java.lang.Thread.run(Thread.java:1589)

So it might be the cover image upload that has errors? What is the "handle" that is missing?

Is there anything I can do?

ErrorxCode commented 2 months ago

This library is no longer maintained. All the progress is moved to this repo.

See #709 & #719