当前位置:网站首页>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
边栏推荐
- Sdl-3 YUV playback
- 【IoT】智能硬件:如何获取硬件产品的wifi信号强度
- Compound RateModel合約解析
- 【Oracle 数据库】奶妈式教程day03 排序查询
- [atcoder1981] short diameter (graph theory thinking)
- You got 8K in the 3-year function test, but you were actually pretending to work hard
- [atcoder1998] stamp Rally
- 【HDU6357】Hills And Valleys(DP)
- big. Js-- use / instance
- 20200810 T2 dispatch money
猜你喜欢

big. Js-- use / instance

Software testing weekly (issue 75): only when you look down, can you see your true self.

零基础自学SQL课程 | UNION 联合查询

如果要存 IP 地址,用什么数据类型比较好?99%人都会答错!

【IoT】项目管理:如何打造更好的跨职能团队?

2022 melting welding and thermal cutting exam exercises and answers

2. Graduated from this course, and the bank has outsourced testing work for more than 4 months. Talk about some real feelings
![[codeforces1019e] raining season](/img/8e/4a96954ee7dae5f81eaae05b5a075b.png)
[codeforces1019e] raining season

二本毕业,银行外包测试工作 4 个月有余。聊聊一些真实感受 ...

Aiop introduction
随机推荐
测试4年裸辞失业,面试15k的测试岗被按在地上摩擦,结局让我崩溃大哭...
[STL source code analysis] summary notes (1): Opening
Classes and objects (Part 2)
【AtCoder2306】Rearranging(拓扑)
QT picture adaptive display control
You got 8K in the 3-year function test, but you were actually pretending to work hard
【编译原理】05-语法制导的语义计算——基于翻译模式的语义计算
【POJ3691】DNA repair (AC自动机+DP)
Aiop introduction
A correction book full of sad tears
pmp到底是什么?
MFC custom string linked list
Wc2020 guessing game
C language inherits memory management mechanism (unfinished)
2022 low voltage electrician operation certificate test question simulation test platform operation
[atcoder2307] tree game
20200803 T3 my friends [divide and conquer NTT optimization recursion]
【Oracle 数据库】奶妈式教程day04 排序查询
Miscellany C language
如何准备PMP新版大纲考试?