Terrance/SkPy

[400 response from PUT] Cannot send same message to multiple groups in a for loop

kinter107 opened this issue · 6 comments

Before we start...

  • I've searched existing issues, but my problem hasn't been reported yet.
  • I've read the documentation (including notes on error messages and rate limiting), but my problem is something else.
  • I've tested the behaviour on Skype for Web, and it works there but not with SkPy.

Summary

can only send files to first id in a list of ids, if you reorder ids then again files are sent to first id (which means ids are correct) and for others you get following error.

Code sample

from skpy import Skype

def sender(ch: Skype, img: io.BytesIO, csv: io.BytesIO) -> int:
    ch.sendFile(img, "report.png", image=True)
    ch.sendFile(csv, "report.csv", image=False)
    return 1

skype = Skype(os.getenv("SKYPE_USER"), os.getenv("SKYPE_PASS"))

# create your own image and csv buffers !
# ids = [id1, id2] (id1 and id2 are group ids with the format: 19:***@thread.skype

for id in ids:
    sender(skype.chats[id], img_buffer, buffered_csv)

Code output

Traceback (most recent call last):
  File "/home/saeid/Desktop/enan/dana-reporter/weather_reporter.py", line 126, in <module>
    sender(skype.chats[id], img_buffer, buffered_csv)
  File "/home/saeid/Desktop/enan/dana-reporter/weather_reporter.py", line 102, in sender
    ch.sendFile(img, "weather_report.png", image=True)
  File "/home/saeid/Desktop/venv/lib/python3.10/site-packages/skpy/chat.py", line 232, in sendFile
    self.skype.conn("PUT", "{0}/content/{1}".format(urlFull, objType),
  File "/home/saeid/Desktop/venv/lib/python3.10/site-packages/skpy/conn.py", line 249, in __call__
    raise SkypeApiException("{0} response from {1} {2}".format(resp.status_code, method, url), resp)
skpy.core.SkypeApiException: ('400 response from PUT https://api.asm.skype.com/v1/objects/0-weu-d6-0b16a368193ff17b996b26fbe2a7f2df/content/imgpsh', <Response [400]>)

Explain your code

The minimal example to reproduce the issue.

SkPy version

0.10.6

Python version

3.10

Anything else?

No response

seems like commenting line 232 in chat.py fixes it :

        self.skype.conn("PUT", "{0}/content/{1}".format(urlFull, objType),
                        auth=SkypeConnection.Auth.Authorize, data=content.read())

The stack trace you've posted doesn't include the actual response text from Skype, so I can't see why they rejected the upload.

From the issue template:

Set the SKPY_DEBUG_HTTP=1 environment variable so that requests to the Skype API are logged.


seems like commenting line 232 in chat.py fixes it

Have you tried actually opening the file after sending with that line commented out? Given that's the one uploading the file content to Skype, you're probably just sending a broken file link pending the content being filled in.

you're right it's a broken file.
i've tried with SKPY_DEBUG_HTTP=1 and here is the results :

<= [22/10 21:15:51] GET https://azeus1-client-s.gateway.messenger.live.com/v1/users/ME/conversations/19:f405b330d4eb4e9eb1fb037694363a21@thread.skype
{'headers': {'RegistrationToken': '***'},
 'params': {'view': 'msnp24Equivalent'}}
=> [22/10 21:15:51] 200
{'Cache-Control': 'no-store, must-revalidate, no-cache',
 'Content-Encoding': 'gzip',
 'Content-Length': '898',
 'Content-Type': 'application/json; charset=utf-8',
 'ContextId': 'tcid=3485897523270438501,server=MN1PEPF00000E87',
 'Date': 'Sun, 22 Oct 2023 17:45:51 GMT',
 'Pragma': 'no-cache',
 'X-Content-Type-Options': 'nosniff'}
{'id': '19:f405b330d4eb4e9eb1fb037694363a21@thread.skype',
 'lastMessage': {'clientmessageid': '1697996669510',
                 'composetime': '2023-10-22T17:44:29.624Z',
                 'content': '<URIObject type="File.1" '
                            'uri="https://api.asm.skype.com/v1/objects/0-weu-d3-d961d7ac4c8e5e3a8d5fe00b0cbab4d3" '
                            'url_thumbnail="https://api.asm.skype.com/v1/objects/0-weu-d3-d961d7ac4c8e5e3a8d5fe00b0cbab4d3/views/thumbnail"><Title>Title: '
                            'weather_report.txt</Title><Description>Description: '
                            'weather_report.txt</Description><OriginalName '
                            'v="weather_report.txt"/><FileSize v="0"/><a '
                            'href="https://login.skype.com/login/sso?go=webclient.xmm&docid=0-weu-d3-d961d7ac4c8e5e3a8d5fe00b0cbab4d3">https://login.skype.com/login/sso?go=webclient.xmm&docid=0-weu-d3-d961d7ac4c8e5e3a8d5fe00b0cbab4d3</a></URIObject>',
                 'conversationLink': 'https://azeus1-client-s.gateway.messenger.live.com/v1/users/ME/conversations/19:f405b330d4eb4e9eb1fb037694363a21@thread.skype',
                 'conversationid': '19:f405b330d4eb4e9eb1fb037694363a21@thread.skype',
                 'from': 'https://azeus1-client-s.gateway.messenger.live.com/v1/users/ME/contacts/8:live:.cid.6d89bbdb50877313',
                 'id': '1697996669621',
                 'messagetype': 'RichText/Media_GenericFile',
                 'originalarrivaltime': '2023-10-22T17:44:29.624Z',
                 'type': 'Message',
                 'version': '1697996669621'},
 'lastUpdatedMessageId': 1697996669621,
 'lastUpdatedMessageVersion': 1697996669621,
 'messages': 'https://azeus1-client-s.gateway.messenger.live.com/v1/users/ME/conversations/19:f405b330d4eb4e9eb1fb037694363a21@thread.skype/messages',
 'properties': {'color': 'hsv_0.5944798301486199,0.9075144508670521,173_0.55320813771518,0.9594594594594594,222',
                'consumptionhorizon': '1696690252789;1696690261583;1696690252680',
                'consumptionhorizonpublished': '1696690252789;1696690261583;1696690252680',
                'isemptyconversation': 'False',
                'isfollowed': 'False',
                'lastimreceivedtime': '2023-10-07T14:24:20.977Z'},
 'targetLink': 'https://azeus1-client-s.gateway.messenger.live.com/v1/threads/19:f405b330d4eb4e9eb1fb037694363a21@thread.skype',
 'threadProperties': {'joiningenabled': 'true',
                      'lastjoinat': '1696688068789',
                      'membercount': '2',
                      'members': '["8:live:saeidnejati00","8:live:.cid.6d89bbdb50877313"]',
                      'topic': 'test, do not check !!!',
                      'version': '1696688660977'},
 'type': 'Conversation',
 'version': 1697996669621}
<= [22/10 21:15:51] GET https://azeus1-client-s.gateway.messenger.live.com/v1/threads/19:f405b330d4eb4e9eb1fb037694363a21@thread.skype
{'headers': {'RegistrationToken': '***'},
 'params': {'view': 'msnp24Equivalent'}}
=> [22/10 21:15:51] 200
{'Cache-Control': 'no-store, must-revalidate, no-cache',
 'Content-Encoding': 'gzip',
 'Content-Length': '566',
 'Content-Type': 'application/json; charset=utf-8',
 'ContextId': 'tcid=3191273688945105067,server=MN1PEPF00000E87',
 'Date': 'Sun, 22 Oct 2023 17:45:51 GMT',
 'Pragma': 'no-cache',
 'X-Content-Type-Options': 'nosniff'}
{'eTag': '"1696688660977"',
 'id': '19:f405b330d4eb4e9eb1fb037694363a21@thread.skype',
 'members': [{'capabilities': ['kickMember'],
              'cid': '0',
              'friendlyName': '',
              'hidden': False,
              'id': '8:live:saeidnejati00',
              'isFollowing': False,
              'isModerator': False,
              'linkedMri': '',
              'role': 'Admin',
              'type': 'ThreadMember',
              'userLink': 'https://azeus1-client-s.gateway.messenger.live.com/v1/users/8:live:saeidnejati00',
              'userTile': ''},
             {'capabilities': ['kickMember'],
              'cid': '0',
              'friendlyName': '',
              'hidden': False,
              'id': '8:live:.cid.6d89bbdb50877313',
              'isFollowing': False,
              'isModerator': False,
              'linkedMri': '',
              'role': 'Admin',
              'type': 'ThreadMember',
              'userLink': 'https://azeus1-client-s.gateway.messenger.live.com/v1/users/8:live:.cid.6d89bbdb50877313',
              'userTile': ''}],
 'messages': 'https://azeus1-client-s.gateway.messenger.live.com/v1/users/ME/conversations/19:f405b330d4eb4e9eb1fb037694363a21@thread.skype/messages',
 'properties': {'capabilities': ['AddMember',
                                 'ChangeTopic',
                                 'ChangePicture',
                                 'EditMsg',
                                 'CallP2P',
                                 'SendText',
                                 'SendSms',
                                 'SendFileP2P',
                                 'SendContacts',
                                 'SendVideoMsg',
                                 'SendMediaMsg',
                                 'ChangeModerated'],
                'createdat': '1696688068788',
                'creator': '8:live:.cid.6d89bbdb50877313;cid=7893046372566790931;skypeid=live:.cid.6d89bbdb50877313',
                'historydisclosed': 'true',
                'joiningenabled': 'true',
                'topic': 'test, do not check !!!'},
 'rosterVersion': 1696688660977,
 'type': 'Thread',
 'version': 1696688660977}
<= [22/10 21:15:51] POST https://api.asm.skype.com/v1/objects
{'headers': {'Authorization': '***', 'X-Client-Version': '0/0.0.0.0'},
 'json': {'filename': 'weather_report.txt',
          'permissions': {'8:live:.cid.6d89bbdb50877313': ['read'],
                          '8:live:saeidnejati00': ['read']},
          'type': 'sharing/file'}}
=> [22/10 21:15:52] 201
{'Content-Length': '51',
 'Content-Type': 'application/json; charset=utf-8',
 'Date': 'Sun, 22 Oct 2023 17:45:52 GMT',
 'Location': 'https://api.asm.skype.com/v1/objects/0-weu-d17-b7947a2f8c0652a33fdddecd532dc367',
 'MS-CV': 'oKvnrJl/zkSzX+G20jUmOQ.0',
 'Server-Timing': 'reqlatency;dur=66',
 'Strict-Transport-Security': 'max-age=2592000; includeSubDomains',
 'X-AMS-Document-Product': 'SFL',
 'X-Cache': 'CONFIG_NOCACHE',
 'X-Content-Type-Options': 'nosniff',
 'X-Data-Center-Alias': 'weu-storage-01',
 'X-Destination-Port': '443',
 'X-Frame-Options': 'DENY',
 'X-Instance-Id': 'ic3-asyncmedia-storage-facek-deployment-dc87859b9-glzts',
 'X-MSEdge-Ref': 'Ref A: FF48E3A98AA5419AB1A651F91934B177 Ref B: DXB20EDGE0313 '
                 'Ref C: 2023-10-22T17:45:52Z',
 'X-ServerApplication': 'FaceK',
 'X-Source-Port': '15624'}
{'id': '0-weu-d17-b7947a2f8c0652a33fdddecd532dc367'}
<= [22/10 21:15:52] PUT https://api.asm.skype.com/v1/objects/0-weu-d17-b7947a2f8c0652a33fdddecd532dc367/content/original
{'data': b'matplotlib==3.7.1\npandas==2.0.1\npython-dotenv==1.0.0\nredis==4.5.'
         b'5\nRequests==2.31.0\nseaborn==0.12.2\nSkPy==0.10.6\n',
 'headers': {'Authorization': '***'}}
=> [22/10 21:15:53] 201
{'Content-Length': '0',
 'Content-Range': 'bytes 0-111/112',
 'Date': 'Sun, 22 Oct 2023 17:45:52 GMT',
 'MS-CV': 'ydixKQdihUq23LWBZDlWRg.0',
 'Server-Timing': 'reqlatency;dur=59',
 'Strict-Transport-Security': 'max-age=2592000; includeSubDomains',
 'X-AMS-Document-Product': 'SFL',
 'X-Cache': 'CONFIG_NOCACHE',
 'X-Content-Type-Options': 'nosniff',
 'X-Data-Center-Alias': 'weu3-storage-nonazsc',
 'X-Destination-Port': '443',
 'X-Frame-Options': 'DENY',
 'X-Instance-Id': 'FaceK_IN_21',
 'X-MSEdge-Ref': 'Ref A: 7C5CBF3B83A14678B45DCC44F23B4B9C Ref B: DXB20EDGE0313 '
                 'Ref C: 2023-10-22T17:45:52Z',
 'X-ServerApplication': 'FaceK',
 'X-Source-Port': '15816'}

<= [22/10 21:15:53] POST https://azeus1-client-s.gateway.messenger.live.com/v1/users/ME/conversations/19:f405b330d4eb4e9eb1fb037694363a21@thread.skype/messages
{'headers': {'ClientInfo': 'os=Windows; osVer=10; proc=x86; lcid=en-US; '
                           'deviceType=1; country=US; clientName=skype4life; '
                           'clientVer=1418/9.99.0.999//skype4life',
             'RegistrationToken': '***'},
 'json': {'clientmessageid': '1697996753366',
          'content': '<URIObject type="File.1" '
                     'uri="https://api.asm.skype.com/v1/objects/0-weu-d17-b7947a2f8c0652a33fdddecd532dc367" '
                     'url_thumbnail="https://api.asm.skype.com/v1/objects/0-weu-d17-b7947a2f8c0652a33fdddecd532dc367/views/thumbnail"><Title>Title: '
                     'weather_report.txt</Title><Description>Description: '
                     'weather_report.txt</Description><OriginalName '
                     'v="weather_report.txt"/><FileSize v="112"/><a '
                     'href="https://login.skype.com/login/sso?go=webclient.xmm&docid=0-weu-d17-b7947a2f8c0652a33fdddecd532dc367">https://login.skype.com/login/sso?go=webclient.xmm&docid=0-weu-d17-b7947a2f8c0652a33fdddecd532dc367</a></URIObject>',
          'contenttype': 'text',
          'messagetype': 'RichText/Media_GenericFile'}}
=> [22/10 21:15:53] 201
{'Cache-Control': 'no-store, must-revalidate, no-cache',
 'Content-Length': '37',
 'Content-Type': 'application/json; charset=utf-8',
 'ContextId': 'tcid=2023588737957434359,server=MN1PEPF00000E87',
 'Date': 'Sun, 22 Oct 2023 17:45:53 GMT',
 'Location': 'https://azeus1-client-s.gateway.messenger.live.com/v1/users/ME/conversations/19:f405b330d4eb4e9eb1fb037694363a21@thread.skype/messages/1697996753481',
 'Pragma': 'no-cache',
 'X-Content-Type-Options': 'nosniff'}
{'OriginalArrivalTime': 1697996753489}
<= [22/10 21:15:53] GET https://api.skype.com/users/self/profile
{'headers': {'X-SkypeToken': '***'}}
=> [22/10 21:15:53] 200
{'Cache-Control': 'must-revalidate, no-cache, stratus-cache-per-request=true',
 'Connection': 'keep-alive',
 'Content-Length': '349',
 'Content-Type': 'application/json; ver=1.0; charset=utf-8',
 'Date': 'Sun, 22 Oct 2023 17:45:53 GMT',
 'Server': 'nginx',
 'Strict-Transport-Security': 'max-age=31536000; includeSubdomains;',
 'Vary': 'Origin',
 'X-Azure-Instance-ID': 'ProfileFrontend_IN_11',
 'X-Azure-Location': 'WestEurope',
 'X-Content-Type-Options': 'nosniff',
 'X-Frame-Options': 'SAMEORIGIN',
 'X-Processing-Time': '0.221',
 'X-Skype-Processing-Time': '113.01580',
 'X-Skype-Request-Id': '7aa3a526',
 'X-Stratus-Endpoint': '/users/:username/profile',
 'X-Stratus-Processing-Time': '0.2185',
 'X-XSS-Protection': '1; mode=block'}
{'about': None,
 'avatarUrl': None,
 'birthday': None,
 'city': None,
 'country': None,
 'emails': ['sa.hara9372@gmail.com'],
 'firstname': 'saeid',
 'gender': '0',
 'homepage': None,
 'jobtitle': None,
 'language': None,
 'lastname': 'nejati',
 'mood': None,
 'phoneHome': None,
 'phoneMobile': None,
 'phoneOffice': None,
 'province': None,
 'richMood': None,
 'username': 'live:.cid.6d89bbdb50877313'}
<= [22/10 21:15:53] GET https://azeus1-client-s.gateway.messenger.live.com/v1/users/ME/conversations/19:5eb5a0009dab4a40bfe4f1ee1d9d5584@thread.skype
{'headers': {'RegistrationToken': '***'},
 'params': {'view': 'msnp24Equivalent'}}
=> [22/10 21:15:54] 200
{'Cache-Control': 'no-store, must-revalidate, no-cache',
 'Content-Encoding': 'gzip',
 'Content-Length': '914',
 'Content-Type': 'application/json; charset=utf-8',
 'ContextId': 'tcid=4494345950544717750,server=MN1PEPF00000E87',
 'Date': 'Sun, 22 Oct 2023 17:45:53 GMT',
 'Pragma': 'no-cache',
 'X-Content-Type-Options': 'nosniff'}
{'id': '19:5eb5a0009dab4a40bfe4f1ee1d9d5584@thread.skype',
 'lastMessage': {'clientmessageid': '1697996670738',
                 'composetime': '2023-10-22T17:44:30.843Z',
                 'content': '<URIObject type="File.1" '
                            'uri="https://api.asm.skype.com/v1/objects/0-weu-d18-f8a895053a8347617a9b2cc0317cdfb5" '
                            'url_thumbnail="https://api.asm.skype.com/v1/objects/0-weu-d18-f8a895053a8347617a9b2cc0317cdfb5/views/thumbnail"><Title>Title: '
                            'weather_report.txt</Title><Description>Description: '
                            'weather_report.txt</Description><OriginalName '
                            'v="weather_report.txt"/><FileSize v="0"/><a '
                            'href="https://login.skype.com/login/sso?go=webclient.xmm&docid=0-weu-d18-f8a895053a8347617a9b2cc0317cdfb5">https://login.skype.com/login/sso?go=webclient.xmm&docid=0-weu-d18-f8a895053a8347617a9b2cc0317cdfb5</a></URIObject>',
                 'conversationLink': 'https://azeus1-client-s.gateway.messenger.live.com/v1/users/ME/conversations/19:5eb5a0009dab4a40bfe4f1ee1d9d5584@thread.skype',
                 'conversationid': '19:5eb5a0009dab4a40bfe4f1ee1d9d5584@thread.skype',
                 'from': 'https://azeus1-client-s.gateway.messenger.live.com/v1/users/ME/contacts/8:live:.cid.6d89bbdb50877313',
                 'id': '1697996670846',
                 'messagetype': 'RichText/Media_GenericFile',
                 'originalarrivaltime': '2023-10-22T17:44:30.843Z',
                 'type': 'Message',
                 'version': '1697996670846'},
 'lastUpdatedMessageId': 1697996670846,
 'lastUpdatedMessageVersion': 1697996670846,
 'messages': 'https://azeus1-client-s.gateway.messenger.live.com/v1/users/ME/conversations/19:5eb5a0009dab4a40bfe4f1ee1d9d5584@thread.skype/messages',
 'properties': {'color': 'hsv_0.5944798301486199,0.9075144508670521,173_0.55320813771518,0.9594594594594594,222',
                'consumptionhorizon': '1696688783527;1696688784619;1696688783407',
                'consumptionhorizonpublished': '1696688783527;1696688784619;1696688783407',
                'isemptyconversation': 'False',
                'isfollowed': 'False',
                'lastimreceivedtime': '2023-10-07T14:15:53.264Z'},
 'targetLink': 'https://azeus1-client-s.gateway.messenger.live.com/v1/threads/19:5eb5a0009dab4a40bfe4f1ee1d9d5584@thread.skype',
 'threadProperties': {'joiningenabled': 'true',
                      'lastjoinat': '1696688152233',
                      'membercount': '3',
                      'members': '["8:live:saeidnejati00","8:live:.cid.ebf6444d268e2d81","8:live:.cid.6d89bbdb50877313"]',
                      'topic': 'test2, do not check !',
                      'version': '1696688152936'},
 'type': 'Conversation',
 'version': 1697996670846}
<= [22/10 21:15:54] GET https://azeus1-client-s.gateway.messenger.live.com/v1/threads/19:5eb5a0009dab4a40bfe4f1ee1d9d5584@thread.skype
{'headers': {'RegistrationToken': '***'},
 'params': {'view': 'msnp24Equivalent'}}
=> [22/10 21:15:54] 200
{'Cache-Control': 'no-store, must-revalidate, no-cache',
 'Content-Encoding': 'gzip',
 'Content-Length': '587',
 'Content-Type': 'application/json; charset=utf-8',
 'ContextId': 'tcid=3309682241077636512,server=MN1PEPF00000E87',
 'Date': 'Sun, 22 Oct 2023 17:45:54 GMT',
 'Pragma': 'no-cache',
 'X-Content-Type-Options': 'nosniff'}
{'eTag': '"1696688152936"',
 'id': '19:5eb5a0009dab4a40bfe4f1ee1d9d5584@thread.skype',
 'members': [{'capabilities': ['kickMember'],
              'cid': '0',
              'friendlyName': '',
              'hidden': False,
              'id': '8:live:saeidnejati00',
              'isFollowing': False,
              'isModerator': False,
              'linkedMri': '',
              'role': 'Admin',
              'type': 'ThreadMember',
              'userLink': 'https://azeus1-client-s.gateway.messenger.live.com/v1/users/8:live:saeidnejati00',
              'userTile': ''},
             {'capabilities': ['kickMember'],
              'cid': '0',
              'friendlyName': '',
              'hidden': False,
              'id': '8:live:.cid.ebf6444d268e2d81',
              'isFollowing': False,
              'isModerator': False,
              'linkedMri': '',
              'role': 'Admin',
              'type': 'ThreadMember',
              'userLink': 'https://azeus1-client-s.gateway.messenger.live.com/v1/users/8:live:.cid.ebf6444d268e2d81',
              'userTile': ''},
             {'capabilities': ['kickMember'],
              'cid': '0',
              'friendlyName': '',
              'hidden': False,
              'id': '8:live:.cid.6d89bbdb50877313',
              'isFollowing': False,
              'isModerator': False,
              'linkedMri': '',
              'role': 'Admin',
              'type': 'ThreadMember',
              'userLink': 'https://azeus1-client-s.gateway.messenger.live.com/v1/users/8:live:.cid.6d89bbdb50877313',
              'userTile': ''}],
 'messages': 'https://azeus1-client-s.gateway.messenger.live.com/v1/users/ME/conversations/19:5eb5a0009dab4a40bfe4f1ee1d9d5584@thread.skype/messages',
 'properties': {'capabilities': ['AddMember',
                                 'ChangeTopic',
                                 'ChangePicture',
                                 'EditMsg',
                                 'CallP2P',
                                 'SendText',
                                 'SendSms',
                                 'SendFileP2P',
                                 'SendContacts',
                                 'SendVideoMsg',
                                 'SendMediaMsg',
                                 'ChangeModerated'],
                'createdat': '1696688152232',
                'creator': '8:live:.cid.6d89bbdb50877313;cid=7893046372566790931;skypeid=live:.cid.6d89bbdb50877313',
                'historydisclosed': 'true',
                'joiningenabled': 'true',
                'topic': 'test2, do not check !'},
 'rosterVersion': 1696688152936,
 'type': 'Thread',
 'version': 1696688152936}
<= [22/10 21:15:54] POST https://api.asm.skype.com/v1/objects
{'headers': {'Authorization': '***', 'X-Client-Version': '0/0.0.0.0'},
 'json': {'filename': 'weather_report.txt',
          'permissions': {'8:live:.cid.6d89bbdb50877313': ['read'],
                          '8:live:.cid.ebf6444d268e2d81': ['read'],
                          '8:live:saeidnejati00': ['read']},
          'type': 'sharing/file'}}
=> [22/10 21:15:54] 201
{'Content-Length': '50',
 'Content-Type': 'application/json; charset=utf-8',
 'Date': 'Sun, 22 Oct 2023 17:45:54 GMT',
 'Location': 'https://api.asm.skype.com/v1/objects/0-weu-d7-ce29b499f164108d78eae5020c2dcabb',
 'MS-CV': 'PCNznyeyA025NrdHPB6Bnw.0',
 'Server-Timing': 'reqlatency;dur=35',
 'Strict-Transport-Security': 'max-age=2592000; includeSubDomains',
 'X-AMS-Document-Product': 'SFL',
 'X-Cache': 'CONFIG_NOCACHE',
 'X-Content-Type-Options': 'nosniff',
 'X-Data-Center-Alias': 'weu-storage-01',
 'X-Destination-Port': '443',
 'X-Frame-Options': 'DENY',
 'X-Instance-Id': 'ic3-asyncmedia-storage-facek-deployment-dc87859b9-glzts',
 'X-MSEdge-Ref': 'Ref A: F978989486AB400DBB7D69DE3BC1FB5C Ref B: DXB20EDGE0313 '
                 'Ref C: 2023-10-22T17:45:54Z',
 'X-ServerApplication': 'FaceK',
 'X-Source-Port': '15624'}
{'id': '0-weu-d7-ce29b499f164108d78eae5020c2dcabb'}
<= [22/10 21:15:54] PUT https://api.asm.skype.com/v1/objects/0-weu-d7-ce29b499f164108d78eae5020c2dcabb/content/original
{'data': b'', 'headers': {'Authorization': '***'}}
=> [22/10 21:15:54] 400
{'Content-Length': '428',
 'Content-Type': 'application/json; charset=utf-8',
 'Date': 'Sun, 22 Oct 2023 17:45:54 GMT',
 'MS-CV': 'D6q5iCtKO0mI89fZpmF+rw.0',
 'Server-Timing': 'reqlatency;dur=6',
 'Strict-Transport-Security': 'max-age=2592000; includeSubDomains',
 'X-AMS-Document-Product': 'SFL',
 'X-Cache': 'CONFIG_NOCACHE',
 'X-Content-Type-Options': 'nosniff',
 'X-Data-Center-Alias': 'weu3-storage-nonazsc',
 'X-Destination-Port': '443',
 'X-Frame-Options': 'DENY',
 'X-Instance-Id': 'FaceK_IN_21',
 'X-MSEdge-Ref': 'Ref A: 515C2877A78E421A9DCDF897AEE15922 Ref B: DXB20EDGE0313 '
                 'Ref C: 2023-10-22T17:45:54Z',
 'X-ServerApplication': 'FaceK',
 'X-Source-Port': '15816'}
{'detail': "See the 'errors' field for more details.",
 'errors': {'headers': ['Invalid content length.']},
 'instance': '/microsoft/ic3/ams/live/westeurope/trace-id/00-33b2798672f7fab12c8ee0dff7b13430-9808fe738ae235c0-00?timestamp=2023-10-22T17:45:54',
 'message': 'One or more validation errors occurred.',
 'status': 400,
 'title': 'One or more validation errors occurred.',
 'traceId': '00-33b2798672f7fab12c8ee0dff7b13430-9808fe738ae235c0-00'}
Traceback (most recent call last):
  File "/home/saeid/Desktop/enan/dana-reporter/weather_reporter.py", line 128, in <module>
    sender(skype.chats[id], f)
  File "/home/saeid/Desktop/enan/dana-reporter/weather_reporter.py", line 103, in sender
    ch.sendFile(csv, "weather_report.txt", image=False)
  File "/home/saeid/Desktop/venv/lib/python3.10/site-packages/skpy/chat.py", line 232, in sendFile
    self.skype.conn("PUT", "{0}/content/{1}".format(urlFull, objType),
  File "/home/saeid/Desktop/venv/lib/python3.10/site-packages/skpy/conn.py", line 249, in __call__
    raise SkypeApiException("{0} response from {1} {2}".format(resp.status_code, method, url), resp)
skpy.core.SkypeApiException: ('400 response from PUT https://api.asm.skype.com/v1/objects/0-weu-d7-ce29b499f164108d78eae5020c2dcabb/content/original', <Response [400]>)

I've just updated your comment as you leaked both your password and your tokens in it (again, please review the issue template) -- I would suggest signing out and changing your password ASAP.

The second, failed file upload appears to empty ('data': b'' sent and Invalid content length returned) -- is it always an empty file that Skype rejects, or can you get a log file showing a non-empty file failing?

Thanks I didn't notice my password in the log. changed it right away.
Your right it's the empty file that Skype rejects, changing code to re-read the files fixed the issue.

Yes, it looks like Skype prevents the sending of empty files, so SkPy won't be able to send them either.

I'd rather not be coding that "business" logic into SkPy (ultimately it's not a SkPy restriction), so the obvious workaround is not to send empty files -- if you're trying to send multiple files, some of which may be empty, you'd probably be better generating a ZIP file containing all your files and sending that instead.