Sending media as chat participant, Conversations API

Open
#596 1 comment 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
45/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Tech stack
python
Domain
api

Research direction

Start in twilio/base/domain.py and trace how client.media.v1 builds the media request URL. Confirm that creating Conversations media targets mcs.us1.twilio.com rather than media.twilio.com, and verify the reported 404 no longer occurs for the provided media upload call.

Written by the indexing model from the issue text.

Description

priority: low status: help wanted type: community enhancement
Issue Summary

Issue is that library is executing POST method onto url = https://media.twilio.com/v1/Services/<Service_SID>/Media instead of https://mcs.us1.twilio.com/v1/Services/<Service_SID>/Media. When I change URL in twilio/base/domain.py everything is working good.

Code Snippet
        with open(os.getenv('PICTURE'), 'rb') as f:
            file = f.read()
        auth = account_sid + ":" + auth_token
        auth_bytes = auth.encode("ascii")

        base64_bytes = base64.b64encode(auth_bytes)
        base64_string = "Basic " + base64_bytes.decode("ascii")

        media = client.media.v1 \
            .create(
                method="POST",
                headers=
                {
                    "Content-Type": "image/png",
                    "Authorization": base64_string},
                data=file,
                uri="/Services/" + os.getenv('DEFAULT_SERVICE_SID') + "/Media")
Exception/Log
Error ::
HTTP 404 error: Unable to create record: The requested resource /Services/<Service_SID>/Media was not found
Technical details:
  • twilio-python version: 7.8.0
  • python version: 3.9
Dominant language
Python
Stars
2.1k
Forks
815
Avg merge
2d 13h
Merged PRs (30d)
2

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from twilio/twilio-python

All issues in twilio/twilio-python

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.