JeffreySu/WeiXinMPSDK · error · ArgumentException
业务申请编号和微信支付申请单编号至少填写一个。
Error message
业务申请编号和微信支付申请单编号至少填写一个。
What it means
CancelApplymentAsync (v3/apply4subject applyment cancel API) needs an identifier for the applyment to cancel: either businessCode (业务申请编号) or applymentId (微信支付申请单编号). If neither yields a non-empty identifier, an ArgumentException is thrown before building the request path.
Solutions
- Pass the businessCode you supplied when creating the applyment.
- Or pass the applymentId returned by WeChat Pay in the applyment response.
- If both are missing, re-query the applyment status first (e.g. via the query API) to recover the id, or skip cancellation since there is nothing to cancel.
Example fix
// before await apis.CancelApplymentAsync(null, null); // after await apis.CancelApplymentAsync(businessCode: "APPLY_20240101_001", applymentId: null); // or await apis.CancelApplymentAsync(null, applymentId: 2000002123456789);
Defensive patterns
Strategy: validation
Validate before calling
// C#
if (string.IsNullOrWhiteSpace(businessCode) && (applymentId is null || applymentId <= 0))
throw new InvalidOperationException("CancelApplyment requires businessCode or applymentId"); Type guard
bool HasApplymentIdentifier(string businessCode, long? applymentId) => !string.IsNullOrWhiteSpace(businessCode) || applymentId.HasValue;
Try / catch
try { await apis.CancelApplymentAsync(businessCode, applymentId); }
catch (ArgumentException ex) when (ex.Message.Contains("至少填写一个")) { log.LogWarning("No applyment identifier available; nothing to cancel"); } Prevention
- Persist the applymentId from the applyment creation response immediately
- Always store businessCode alongside order records
- Only invoke cancel when at least one identifier was recorded
When it happens
Trigger: Calling CancelApplymentAsync with businessCode null/whitespace AND applymentId null (or a nullable that HasValue == false).
Common situations: The applyment flow stored neither code because the apply request failed earlier, or businessCode was trimmed to empty and applymentId was never persisted, so cancellation cannot target any application.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- 不能为空。
- out_trade_no、transaction_id、sub_order_no 和 sub_order_id…
- out_trade_no 和 transaction_id 至少填写一个。
- AppId 不能为空。
- AppId 不能为空。
AI-assisted analysis of JeffreySu/WeiXinMPSDK@be573f6f94 (2026-09-12).
Data as JSON: /api/errors/1060e1877ecdccd1.
Report an issue: GitHub.
Appendix: source
Thrown at src/Senparc.Weixin.TenPay/Senparc.Weixin.TenPayV3/Apis/Apply4Subject/Apply4SubjectApis.Current.cs:68
timeOut);
}
/// <summary>
/// 撤销商户开户意愿确认申请单。
/// </summary>
/// <param name="businessCode">业务申请编号,与 applymentId 至少填写一个。</param>
/// <param name="applymentId">微信支付申请单编号,与 businessCode 至少填写一个。</param>
/// <param name="timeOut">代理请求超时时间(毫秒)。</param>
/// <returns>微信支付接口结果;成功时官方返回 HTTP 204。</returns>
public Task<ReturnJsonBase> CancelApplymentAsync(string businessCode = null,
long? applymentId = null, int timeOut = Config.TIME_OUT)
{
var identifier = !string.IsNullOrWhiteSpace(businessCode)
? businessCode
: applymentId?.ToString();
if (string.IsNullOrWhiteSpace(identifier))
{
throw new ArgumentException("业务申请编号和微信支付申请单编号至少填写一个。");
}
var path = $"v3/apply4subject/applyment/{Escape(identifier)}/cancel";
if (!string.IsNullOrWhiteSpace(businessCode) && applymentId.HasValue)
{
path += $"?applyment_id={applymentId.Value}";
}
var request = new TenPayApiRequest(_tenpayV3Setting);
return request.RequestWithoutBodyAsync<ReturnJsonBase>(GetUrl(path), timeOut);
}
/// <summary>
/// 查询商户开户意愿确认申请单审核结果。
/// </summary>
/// <param name="applymentId">微信支付申请单编号,与 businessCode 至少填写一个。</param>
/// <param name="businessCode">业务申请编号,与 applymentId 至少填写一个。</param>
/// <param name="timeOut">代理请求超时时间(毫秒)。</param>View on GitHub (pinned to be573f6f94)