5

I am trying to upload a video to Tiktok using this endpoint:

https://open-api.tiktok.com/share/video/upload/

Following the official docs: https://developers.tiktok.com/doc/web-video-kit-with-web

(After successfully authenticating with Tiktok and getting an access token using the Login Kit API). I am getting a response that suggests success (with error_code=0 and a non-empty share_id), however nothing gets uploaded and my Tiktok app's callback url does not seem to be getting triggered with any status update.

I've tried hitting the API from several different environments - a Node.js runtime (using Axios), a cURL request from 2 different machines (all getting the result described above) and also from my frontend code using Fetch (this one got me a CORS error). Code snippets below.

Will appreciate any help since I'm out of ideas as for what to try next. Also if there are any other docs or online resources besides the one I linked to that might be helpful, any links to such will be great.

Note: I made sure my test videos are satisfying the constraints mentioned in the docs.

My Node.js code:

    const url = `https://open-api.tiktok.com/share/video/upload?open_id=${openId}&access_token=${accessToken}`;
const data = new FormData();
data.append('video', fs.createReadStream(path.join(os.tmpdir(), 'test.mp4')));
await axios.post(url, data, {
  headers: data.getHeaders()
});

cURL request:

curl --location --request POST 'https://open-api.tiktok.com/share/video/upload?open_id=<open_id>&access_token=<access_token>' --form 'video=@"/path/to/video.mp4"'

Response payload (for both cURL and Node.JS requests):

{"data":{"err_code":0,"error_code":0,"share_id":"video.7031619168818448385.CGdXCmaC"},"extra":{"error_detail":"","logid":"2021111721133201024513311411A971D3"}}

Frontend code (Fetch, getting a 307 response with the same Tiktok URL (/share/video/upload...) in the Location header - resulting in CORS error):

const formData = new FormData();
formData.append('video', selectedFile);

const requestOptions = {
  method: 'POST',
  body: formData,
  redirect: 'follow'
};

const URL = `https://open-api.tiktok.com/share/video/upload?access_token=${accessToken}&open_id=${openId}`;

fetch(URL, requestOptions)
  .then((response) => response.text())
  .then((result) => console.log(result))
  .catch((error) => console.log('error', error));
giladmaker
  • 61
  • 1
  • 3

2 Answers2

5

You need to download the TikTok app then publish the video uploaded by your API.

The user who triggered the video upload should receive a notification on TikTok App after the video uploaded successfully and the user can publish the video on the app.

Nathan Dai
  • 392
  • 2
  • 11
  • I can not find this anywhere on the official document, but it appears to be the correct process. – Chen Dec 09 '21 at 15:07
1

In case you get "Something went wrong, try again later". It is probably your region issue. You will need to try a vpn and try again.

  • Hi Junaid, what region do you suggest we should connect to? I'm having the same issue right now. – omenocal Jun 03 '22 at 17:43
  • I am facing the same problem. Video is successfully posted via. Postman. I receive that the video is ready in my phone but when I tap it, it says "Something went wrong. Try again." Any help would be appreciated. Thanks. – Shameel Uddin Jun 29 '22 at 18:11
  • Hotspot shield with US region worked fine for me. But i''ve seen people use different and better VPNs and still get the issue so trying different regions might help. – Junaid Shad Jul 15 '22 at 05:13