Temporary Asset enterprise micro-channel upload with Chinese name error 44001: empty media data

Cause of error: urllib3 old version bug, uninstall requests, urllib3, re-install the latest version of the requests (inside this package relies urllib3);

I installed the new requests == 2.22.0 and urllib3 == 1.25.3 package

 

Upload a temporary resource code is as follows (this code supports uploading files and users receive files are displayed as Chinese case):

    DEF upload_temp_file (Self, token, userid, file_abs_path, file_type, file_name):
         "" " 
        upload temporary asset 
        interface documentation Address: HTTPS: //work.weixin.qq.com/api/doc#90000/90135/90253 

        : param token micro-channel business: token 
        : param userid: user enterprise micro-channel the above mentioned id 
        : param file_abs_path: To upload a file absolute path 
        : param file_type: file type 
        a file name that is displayed when users receive documents:: param file_name 
        : return: BOOL, str 
        " "" 

        # check FILE_TYPE 
        support_file_type = [ ' Image ' , ' Voice ' , ' Video ' , 'file']
         IF file_type not  in support_file_type: 
            log.error (f ' error File of the type, only support_file_type Support {} ' )
             return False, None 

        # file a bug workaround named Chinese: https: //blog.csdn.net/u013250071/ Article This article was / Details / 82,493,892 
        file_upload_result = requests.post (
             ' https://qyapi.weixin.qq.com/cgi-bin/media/upload?access_token= & type = {} {} ' .format (token, FILE_TYPE), 
            Files {= ' Media ' : (file_name, Open (file_abs_path, ' RB ' ),'', {})}
        )

 

 

Micro letter sent to business results:

 

 

to sum up:

1. docking third-party interfaces, through code problems when docking, docking with the postman on other tools, if you use the tool butt no problem, most likely the problem is the code, not a third-party platform rubbish;

2. Do not forget the bug might be considered open source packages used, if Baidu or Google keyword (python enterprise micro-channel upload temporary material 44001 Chinese empty media data) can not find an answer to; just try to find other keywords such as ( python requests post Chinese documents);

3. can not find a bug, put a bag unloading equipment from the latest, after all, may be used before the package is a bug in older versions of unrepaired

 

 

Related Links:

https://blog.csdn.net/u013250071/article/details/82493892

Guess you like

Origin www.cnblogs.com/rgcLOVEyaya/p/RGC_LOVE_YAYA_1122_days.html