Skip to content
This repository has been archived by the owner on Oct 1, 2023. It is now read-only.

Issue with post creation #43

Closed
Xehos opened this issue Jul 16, 2023 · 2 comments
Closed

Issue with post creation #43

Xehos opened this issue Jul 16, 2023 · 2 comments

Comments

@Xehos
Copy link

Xehos commented Jul 16, 2023

Hello,
whenever I try to post a new Thread I'm getting this error right after message:
INFO:Set logged-in state successfully. All set!

DEBUG:Starting new HTTPS connection (1): i.instagram.com:443
DEBUG:https://i.instagram.com:443 "POST /api/v1/media/configure_text_only_post/ HTTP/1.1" 404 21807
[ERROR]  Failed to decode response as JSON
Traceback (most recent call last):
  File "/home/sites/26a/0/09b25bf6df/.local/lib/python3.10/site-packages/requests/models.py", line 971, in json
    return complexjson.loads(self.text, **kwargs)
  File "/home/sites/26a/0/09b25bf6df/.local/lib/python3.10/site-packages/simplejson/__init__.py", line 514, in loads
    return _default_decoder.decode(s)
  File "/home/sites/26a/0/09b25bf6df/.local/lib/python3.10/site-packages/simplejson/decoder.py", line 386, in decode
    obj, end = self.raw_decode(s)
  File "/home/sites/26a/0/09b25bf6df/.local/lib/python3.10/site-packages/simplejson/decoder.py", line 416, in raw_decode
    return self.scan_once(s, idx=_w(s, idx).end())
simplejson.errors.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/sites/26a/0/09b25bf6df/public_html/reqs.py", line 26, in post
    resp = response.json()
  File "/home/sites/26a/0/09b25bf6df/.local/lib/python3.10/site-packages/requests/models.py", line 975, in json
    raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)
requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/sites/26a/0/09b25bf6df/public_html/test.py", line 27, in <module>
    loop.run_until_complete(main())
  File "/usr/lib64/python3.10/asyncio/base_events.py", line 646, in run_until_complete
    return future.result()
  File "/home/sites/26a/0/09b25bf6df/public_html/test.py", line 23, in main
    await post()
  File "/home/sites/26a/0/09b25bf6df/public_html/test.py", line 13, in post
    result = await api.post("Hello world!")
  File "/home/sites/26a/0/09b25bf6df/.local/lib/python3.10/site-packages/threads_api/src/threads_api.py", line 107, in wrapper
    return await func(self, *args, **kwargs)
  File "/home/sites/26a/0/09b25bf6df/.local/lib/python3.10/site-packages/threads_api/src/threads_api.py", line 1079, in post
    res = await self._private_post(url=post_url, headers=headers,data=payload)
  File "/home/sites/26a/0/09b25bf6df/.local/lib/python3.10/site-packages/threads_api/src/threads_api.py", line 107, in wrapper
    return await func(self, *args, **kwargs)
  File "/home/sites/26a/0/09b25bf6df/.local/lib/python3.10/site-packages/threads_api/src/threads_api.py", line 157, in _private_post
    return await self._auth_session.post(**kwargs)
  File "/home/sites/26a/0/09b25bf6df/public_html/reqs.py", line 32, in post
    raise Exception('Failed to decode response as JSON')
Exception: Failed to decode response as JSON

Does anyone know what should this one mean? Thanks

@Danie1
Copy link
Owner

Danie1 commented Jul 16, 2023

Hi, thanks for choosing threads-api :)

It means that the HTTP response you received from Threads.net is not as expected. One reason could be that the underlying authentication timed out or is no longer valid.

Please set LOG_LEVEL environment variable to DEBUG so you are able to see the full response. It usually hints as to why it had failed. You can run your script like this: LOG_LEVEL=DEBUG python3 main.py to include it.

If you need further assistance, please add additional details from the logs.

@Danie1
Copy link
Owner

Danie1 commented Jul 18, 2023

Please re-open with additional info if still reproduces after version v1.1.13 (https://github.com/Danie1/threads-api/releases/tag/v1.1.13). It contains improvements in this area / the solution, so at the very least it will be easier to troubleshoot if a different issue appears.

@Danie1 Danie1 closed this as completed Jul 18, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants