Facebook Meta Resumable Upload API Permission Error Unsupported post request. Object with ID 'upload:MT....'

60 Views Asked by At

I am trying to upload media using Resumable Upload API

But i am getting error in 2nd step:

[
    "error" => [
      "message" => "Unsupported post request. Object with ID 'upload:MTphdHRhY2htZW50OjY1NGY1OTNlLTVjNzMtNDkwNy05YmJhLWM4Y2M3MjU0ZjRkMT9maWxlX2xlbmd0aD00NTE0NzkmZmlsZV90eXBlPWltYWdlJTJGanBlZw==?sig=ARYbfnegf0MmYhwi1jk' does not exist, cannot be loaded due to missing permissions, or does not support this operation. Please read the Graph API documentation at https://developers.facebook.com/docs/graph-api",
      "type" => "GraphMethodException",
      "code" => 100,
      "error_subcode" => 33,
      "fbtrace_id" => "A2ESWA2-36zZ3cbJ0A1W7XZ",
    ],
  ]

I am using Laravel HTTP Client,

$file = new Symfony\Component\HttpFoundation\File\File($filePath)

$url = "https://graph.facebook.com/v18.0/1849***********/uploads?file_length={$file->getSize()}&file_type={$file->getMimeType()}";
//https://graph.facebook.com/v18.0/1849***********/uploads?file_length=45455&file_type=image/jepg

$session = Http::acceptJson()
     ->contentType("application/json")
     ->withToken($USER_TOKEN)
     ->post($url)
     ->json()

$encoded = urlencode($session["id"]);
$url = "https://graph.facebook.com/v18.0/{$encoded}";
$response = Http::acceptJson()
      ->attach('file', $file->getContent(), $file->getFilename())
      ->withToken($USER_TOKEN, "OAuth")
      ->withHeaders([
                'Content-Type'=> 'multipart/form-data',
                "file_offset" => 0
            ])
      ->post($url);
0

There are 0 best solutions below