question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] - TikTok sent invalid JSON back

See original GitHub issue

Read Below!!! If this doesn’t fix your issue delete these two lines

You may need to install chromedriver for your machine globally. Download it here and add it to your path.

Describe the bug TikTok sent invalid JSON back.

The buggy code

Please insert the code that is throwing errors or is giving you weird unexpected results.

from TikTokApi import TikTokApi
import random
import os
api = TikTokApi.get_instance(custom_verifyFp=os.environ.get("verifyFp", None))
did = str(random.randint(10000, 999999999))
t = api.byUsername('therock', did=did, custom_verifyFp='your_verify_fp')[0]
print(t)
v_bytes = api.get_Video_By_TikTok(t, did=did, custom_verifyFp='your_verify_fp')
with open("test.mp4", 'wb') as o:
    o.write(v_bytes)

Expected behavior

A clear and concise description of what you expected to happen.

Error Trace (if any)

Put the error trace below if there’s any error thrown.

# Error Trace Here

ERROR:root:TikTok response: illegal request… ERROR:root:Converting response to JSON failed ERROR:root:Expecting value: line 1 column 1 (char 0) Traceback (most recent call last): File “C:\Users\john\anaconda3\envs\tiktok_new\lib\site-packages\TikTokApi\tiktok.py”, line 173, in getData json = r.json() File “C:\Users\john\anaconda3\envs\tiktok_new\lib\site-packages\requests\models.py”, line 900, in json return complexjson.loads(self.text, **kwargs) File “C:\Users\john\anaconda3\envs\tiktok_new\lib\json_init_.py”, line 348, in loads return _default_decoder.decode(s) File “C:\Users\john\anaconda3\envs\tiktok_new\lib\json\decoder.py”, line 337, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File “C:\Users\john\anaconda3\envs\tiktok_new\lib\json\decoder.py”, line 355, in raw_decode raise JSONDecodeError(“Expecting value”, s, err.value) from None json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File “temp.py”, line 6, in <module> t = api.byUsername(‘therock’, did=did, custom_verifyFp=‘your_verify_fp’)[0] File “C:\Users\john\anaconda3\envs\tiktok_new\lib\site-packages\TikTokApi\tiktok.py”, line 493, in byUsername **kwargs, File “C:\Users\john\anaconda3\envs\tiktok_new\lib\site-packages\TikTokApi\tiktok.py”, line 451, in userPosts res = self.getData(url=api_url, **kwargs) File “C:\Users\john\anaconda3\envs\tiktok_new\lib\site-packages\TikTokApi\tiktok.py”, line 191, in getData raise JSONDecodeFailure() from e TikTokApi.exceptions.JSONDecodeFailure: TikTok sent invalid JSON back

Desktop (please complete the following information):

  • OS: [e.g. Windows 10]
  • TikTokApi Version [e.g. 3.3.1] - 3.8.1

Additional context Referred to #374 for bugfix. Add any other context about the problem here.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
thanhnguyen1121commented, Nov 25, 2020

I don’t know how to get it in python. But when I decode tiktok in web after confirming, I get an api like this: “https://www.tiktok.com/node/share/user/@your_tiktok_username?verifyFp=verify_khwsg04i_Kjx9V5Ev_u6d2_4UiG_8p2n_LAsK5DB

0reactions
viniciusaocommented, Dec 5, 2020

I don’t know how to get it in python. But when I decode tiktok in web after confirming, I get an api like this: “https://www.tiktok.com/node/share/user/@your_tiktok_username?verifyFp=verify_khwsg04i_Kjx9V5Ev_u6d2_4UiG_8p2n_LAsK5DB

you could instantiate TikTokApi object with the custom_verifyFp=‘yourcookievalue’ api = TikTokApi(custom_verifyFp='yourcookievalue')

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why cant Python request parse TikTok API data?
Maybe it's not JSON, but some kind of other encoding. Also, you should check the response headers. To play with this, I'd recommend...
Read more >
How to Fix the Invalid JSON Response Error in WordPress
Check your WordPress site URL.​​ Another common cause of the invalid JSON response error is a problem with your WordPress site URLs. The...
Read more >
Requesting your data - TikTok Help Center
To request your TikTok data: 1. In the TikTok app, tap Profile at the bottom. 2. Tap the Menu button at the top....
Read more >
I've received an "Invalid JSON string" error. What do I do?
An invalid JSON error can occur for many reasons. The most common issue is usually associated with a file upload attempt, and can...
Read more >
Authentication API reference - Stytch
The untrusted_metadata field contains an arbitrary JSON object of application-specific data. Untrusted metadata can be edited by end users directly via the ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found