Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] - TikTokApi.exceptions.EmptyResponseException: None -> TikTok returned an empty response #1188

Open
obscure723 opened this issue Aug 21, 2024 · 7 comments
Labels
bug Something isn't working

Comments

@obscure723
Copy link

Describe the bug
The TikTokApi is returning an empty response when trying to fetch user information, resulting in an EmptyResponseException.

The buggy code

import logging
from TikTokApi import TikTokApi
import asyncio

TikTokApi(logging_level=logging.INFO)  # SETS LOGGING_LEVEL TO INFO

async def user_example2():
    async with TikTokApi() as api:
        await api.create_sessions(ms_tokens=[ms_token], num_sessions=1, sleep_after=3)
        user = api.user("therock")
        user_data = await user.info()
        print(user_data)

        async for video in user.videos(count=30):
            print(video)
            print(video.as_dict)

        async for playlist in user.playlists():
            print(playlist)

def job():
    asyncio.run(user_example2())

if __name__ == "__main__":
    job()

Expected behavior
The code should fetch and print user information, videos, and playlists for the user "therock".

Error Trace (if any)

Traceback (most recent call last):
  File "/app/main.py", line 1033, in <module>
    job()
  File "/app/main.py", line 1021, in job
    asyncio.run(user_example2())
  File "/usr/local/lib/python3.9/dist-packages/nest_asyncio.py", line 30, in run
    return loop.run_until_complete(task)
  File "/usr/local/lib/python3.9/dist-packages/nest_asyncio.py", line 98, in run_until_complete
    return f.result()
  File "/usr/lib/python3.9/asyncio/futures.py", line 201, in result
    raise self._exception
  File "/usr/lib/python3.9/asyncio/tasks.py", line 256, in __step
    result = coro.send(None)
  File "/app/main.py", line 1009, in user_example2
    user_data = await user.info()
  File "/usr/local/lib/python3.9/dist-packages/TikTokApi/api/user.py", line 76, in info
    resp = await self.parent.make_request(
  File "/usr/local/lib/python3.9/dist-packages/TikTokApi/tiktok.py", line 451, in make_request
    raise EmptyResponseException(result, "TikTok returned an empty response")
TikTokApi.exceptions.EmptyResponseException: None -> TikTok returned an empty response

Desktop (please complete the following information):

  • OS: macOS (M1 Mac)
  • TikTokApi Version: 6.4.0

Additional context

  • The error occurs when trying to fetch user information using user.info(). The API is returning an empty response, which is causing an EmptyResponseException to be raised. This prevents the rest of the code (fetching videos and playlists) from executing.
  • The ms_token is obtained from the user's own browser.
  • The issue is occurring on an M1 Mac, which might potentially affect the behavior due to the different architecture.
@obscure723 obscure723 added the bug Something isn't working label Aug 21, 2024
@itsEricWu
Copy link

+1

2 similar comments
@wpz5159582
Copy link

+1

@moonzlo
Copy link

moonzlo commented Aug 29, 2024

+1

@Gereks123
Copy link

Check out this open issue, might help you resolve the issue! #1179 (comment)

@obscure723
Copy link
Author

thank you.I will review this open issue.

Check out this open issue, might help you resolve the issue! #1179 (comment)

@zakrian07
Copy link

zakrian07 commented Sep 2, 2024 via email

@Gereks123
Copy link

this is not working solution

On Sun, Sep 1, 2024 at 4:27 PM よねかん(YONEDA KAN) @.> wrote: thank you.I will review this open issue. Check out this open issue, might help you resolve the issue! #1179 (comment) <#1179 (comment)> — Reply to this email directly, view it on GitHub <#1188 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABPI5XP7SIFEZRHI72E25WLZUL23JAVCNFSM6AAAAABM4WZTYKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGMRTGI4TONRTGQ . You are receiving this because you are subscribed to this thread.Message ID: @.>

#1179 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants