当前位置:网站首页>C wechat upload form data
C wechat upload form data
2022-06-11 07:40:00 【Qianjinshao】
Wechat applet audit sometimes requires image upload verification Using or from-data Format , Very pitiful
The official documents are not clear at all
Request address :
https://api.weixin.qq.com/wxa/uploadmedia?access_token=ACCESS_TOKEN
Here are some places where you can upload , I often report errmsg=media data missing rid: 629f1365-2b583ac9-3f11b616, After an afternoon's test, I finally found out the reason .httpClient Will automatically boundary Auto double quotes , Cause the call to fail . So it needs to be handled manually

Attached directly at the end C# Uploaded code
public async Task<string> AccessFormData(string url, HttpPostedFileBase file, string key)
{
var httpClient = new HttpClient();
var content = new MultipartFormDataContent();
var boundaryValue = content.Headers.ContentType.Parameters.Single(p => p.Name == "boundary");
boundaryValue.Value = boundaryValue.Value.Replace("\"", string.Empty);
if (file?.InputStream != null)
{
content.Add(new StreamContent(file.InputStream, (int) file.InputStream.Length), $"\"{key}\"",
$"\"{file.FileName}\"");
var response = await httpClient.PostAsync(url, content);
return await response.Content.ReadAsStringAsync();
}
return string.Empty;
}there key That's it. media
边栏推荐
- Zero foundation self-study SQL course | outer join external connection
- C memory alignment
- 【AtCoder2304】Cleaning
- Uoj 553 [unr 4] caproic acid set [computational geometry (points in circle → points in half plane)]
- 远程办公经验 | 社区征文
- 20200727 T2 small w playing game [generating function (binomial inversion technique)]
- Wc2020 guessing game
- 【CodeForces908H】New Year and Boolean Bridges (FWT)
- How to prepare for the new PMP syllabus exam?
- [Oracle database] mammy tutorial day02 use of database management tool sqlplus
猜你喜欢

Paging of the flask page
![20200803 T3 my friends [divide and conquer NTT optimization recursion]](/img/35/01201e3136e3dd5cd562a0481f1ee9.jpg)
20200803 T3 my friends [divide and conquer NTT optimization recursion]
![[software testing] 90% of the interviewers have been brushed out of such resumes](/img/2f/bb4819b98592f750dec92d4b4dd6b7.png)
[software testing] 90% of the interviewers have been brushed out of such resumes

Import on CSDN MD file

2. Graduated from this course, and the bank has outsourced testing work for more than 4 months. Talk about some real feelings

After 4 years of naked resignation from the test, the test post of 15K interview was rubbed on the ground, and the result made me collapse and cry

Several transaction modes of Seata
![[Oracle database] mammy tutorial day02 use of database management tool sqlplus](/img/f2/8f6f74a62427ebfb4c805c1e9b3352.png)
[Oracle database] mammy tutorial day02 use of database management tool sqlplus

Use of wordcloud

二本畢業,銀行外包測試工作 4 個月有餘。聊聊一些真實感受 ...
随机推荐
[analysis of STL source code] summary notes (6): Design of iterator and magical traits
[STL source code analysis] summary notes (7): ingenious deque
[STL source code analysis] summary notes (10): hashtable exploration
【Oracle 数据库】奶妈式教程day02 数据库管理工具SQLPLUS的使用
Analyse du contrat du modèle de taux composé
C language to write a calculator MVC (very interesting code architecture callback and constructor mode and the use of pointer functions)
【AtCoder1998】Stamp Rally(整体二分+并查集)
Arduino_ STM development record
3年功能测试拿8K,被新来的反超,其实你在假装努力
After 4 years of naked resignation from the test, the test post of 15K interview was rubbed on the ground, and the result made me collapse and cry
[compilation principle] 05- syntax guided semantic computing -- Semantic Computing Based on translation mode
【AtCoder2304】Cleaning
20200730 T3 small B farm [maximum perimeter empty rectangle (monotone stack + line segment tree)] & "ROI 2017 day 2" learning track
20200803 T3 my friends [divide and conquer NTT optimization recursion]
【编译原理】05-语法制导的语义计算——基于翻译模式的语义计算
What exactly is PMP?
nosqlzoo刷题-1
How to prepare for the new PMP syllabus exam?
群晖DS918创建m.2 固态硬盘SSD读写缓存
【IoT】项目管理:如何打造更好的跨职能团队?