Error while upload a video to the stream using APIs

Type

Video

What is the error number?

10004

What is the error message?

invalid character ‘-’ in numeric literal

What is the issue you’re encountering

I’m trying to upload a video file to Cloudflare Stream using the API in Laravel, but I’m receiving the following error response:

What are the steps to reproduce the issue?

Here is my laravel code

Route::post(‘/t’, function (Request $request) {

// Call Cloudflare API to upload the 
$videoFile = $request->file('file');

$response = Http::withHeaders([
    'Authorization' => 'Bearer <token>',
])
    ->attach('file', fopen($videoFile->getRealPath(), 'r'), $videoFile->getClientOriginalName())

    ->post('https://api.cloudflare.com/client/v4/accounts/<id>/stream/videos');
    dd($response->body());


if ($response->successful()) {
    $data = $response->json();

    // Return the video ID to the frontend
    return response()->json(['data' => $data], 201);
} else {
    return response()->json(['error' => 'Failed to upload video'], 500);
}

});

and here is the response from cloudflare

{

“result”: null,

“success”: false,

“errors”: [

{

  "code": 10004,

  "message": "Decoding Error: A portion of the request could be not decoded. Refer to the messages field for more information and try again."

}

],

“messages”: [

{

  "code": 10004,

  "message": "invalid character '-' in numeric literal"

}

]

}

Since it’s Laravel, may I ask if you’ve wanted a direct upload of e.g. mp4 file, or via an existing URL? :thinking:

To double-check, may I ask if you aren’t missing some more Headers such as X-Auth-Email in your request?

I am not familiar with such HTTP URL request :thinking: Could be I am wrong and missing something, cannot find it in the API?

Hello, and thank you for your response!

If it were a credentials issue, I would expect a more logical error related to the authorization bearer token or another header-related problem. However, since the direct upload is indicating a video encoding error, it seems less likely to be related to authentication. I’ve tried various formats, including MP4, but still encounter the same error.

I’ve reviewed the documentation thoroughly, yet I haven’t found any information that directly addresses this issue. If you have any additional insights or troubleshooting steps, I’d appreciate it! Thank you again for your support.