1

I trying to upload video to facebook using the graph-api v2.3 and qNetworkAccessManager. I succesfully pass authorisation and starts the uploading process, but uploading the first chunk ends with http error 500 and facebook api error code 1363030. It looks just like fb servers is inaccesable, but old api (2.1) just works fine. So, I think, it might be a my problem. There is a part of code where I posting the video chunk

QNetworkRequest request;
request.setUrl(QUrl(QString("https://graph-video.facebook.com/v2.3/me/videos")));
QHttpMultiPart *body = new QHttpMultiPart(QHttpMultiPart::FormDataType);

_file = new QFile(filename);
_file->open(QIODevice::ReadOnly);

QHttpPart tokenPart, phasePart, sessionPart, offsetPart, dataPart;
tokenPart.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; name=\"access_token\""));
tokenPart.setBody(accessToken.toUtf8());

phasePart.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; name=\"upload_phase\""));
phasePart.setBody(phaseTransfer.toUtf8());

sessionPart.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; name=\"upload_session_id\""));
sessionPart.setBody(_sessionId.toUtf8());

offsetPart.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; name=\"start_offset\""));
offsetPart.setBody(QString::number(_startOffset).toUtf8());

QHttpPart dataPart;
dataPart.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; name=\"video_file_chunk\""));
QByteArray data = _file->read(_endOffset - _startOffset);
dataPart.setBody(data);

body->append(tokenPart);
body->append(phasePart);
body->append(offsetPart);
body->append(sessionPart);
body->append(dataPart);

_server->post(request, body);

Maybe someone knows the solution or just have a working sample for graph-api v2.3?

N1ghtroad
  • 11
  • 3
  • Are you seeing the same behavior when talking to the Graph API directly (using cURL)? – Björn Kaiser Jun 24 '15 at 10:05
  • No, with cURL all works fine. Maybe something wrong with dataPart? Documentations says that "The video chunk, encoded as form data", and I'm not shure that my data match these requirement. – N1ghtroad Jun 26 '15 at 08:10
  • I'm having the same issue here, with resumable and non resumable upload. The error user message says that the request timed out, but the error message says "Service temporarily unavailable". Does anybody know if this might be some issue with the Facebook server? – felippeduran Jul 17 '15 at 14:20

2 Answers2

4

Just hit this in Node.js, and hoping to save others some time.

This Facebook error occurs if you don't specify the content type and/or the file name of the attached file. Not sure if only one of them or both are important.

Update your headers to say:

Content-Disposition: form-data; name="source"; filename="video.mp4"
Content-Type: video/mp4

and it'll work fine.

(If someone came here looking for JavaScript code, see this answer for some examples.)

Community
  • 1
  • 1
Andrey Tarantsov
  • 8,965
  • 7
  • 54
  • 58
  • Note that if you're using PHP, you can supply `source` with a value created by `new CurlFile()` which may solve your problems. It did for me! (On the deprecated v3 SDK) – rinogo Aug 30 '17 at 01:26
  • 1
    Note that you do not need to supply an extension in the filename (`video` works just fine) nor a `video/...` mime-type (`application/octet-stream` works just fine). Guess FB figures out the format for you. – Erwin Wessels Oct 09 '18 at 07:34
0

I am facing same problem with graph api v2.8 postman. In my case I am providing the video file but not providing the 'source' parameter.

I resolved by this way. Post Url should be like

https://graph-video.facebook.com/v2.8/{user-id}/videos?access_token={token}

In postman body part, Select form-data radio button and type=file then Provide source={Choose Video file} parameter in form-data body part of postman.

Check https://stackoverflow.com/a/16022213/1294870 for postman configuration

Community
  • 1
  • 1
NIrav Modi
  • 6,038
  • 8
  • 32
  • 47