You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

迁移至MobileFirst 8后调用图片上传API出现414 URI过长错误

Fixing 414 URI Too Long Error When Uploading Base64 Images in MFP 8 Upgrade

Let's break down why you're hitting this 414 error and how to fix it quickly:

Root Cause

The key difference between your MFP 7.1 and MFP 8 code is how parameters are sent to the adapter:

  • In MFP 7.1, WL.Client.invokeProcedure automatically sends the adapter parameters in the POST request body, which has no strict length limits (beyond server configs).
  • In your MFP 8 code, you're using setQueryParameter('params', [invocationData]) to pass the data—this shoves all your parameters (including the large Base64-encoded photo) into the URL's query string. URLs have strict length limits (usually around 2KB-8KB depending on server/browser), so the Base64 photo easily pushes it over the edge, triggering the 414 error.

Solution: Send Parameters in the Request Body

Modify your MFP 8 code to send parameters in the POST body instead of the URL query string. Here's the corrected code:

var locale = localStorageService.get('locale');
var rptList = localStorageService.get('rptList');
var channel = localStorageService.get('rptChannel');
var os = localStorageService.get('rptOs');
var type = localStorageService.get('rptOption');
var station = localStorageService.get('mrReportHistoryDetailStation');
var desc = localStorageService.get('mrReportHistoryDetailDesc');
var loc = localStorageService.get('rptLoc');
var accNo = localStorageService.get('rptAccNo');
var issueType = localStorageService.get('rptIssueType');
var photo = localStorageService.get('rptPhoto');
console.log(rptList);
console.log('Make Report adapter');
var deferred = $q.defer();
var invocationData = {
 LOCALE: locale,
 CHANNEL: channel,
 CLIENT_OS: os,
 TYPE: type,
 ISSUE_TYPE: issueType,
 STATION: type === 'GENERAL_INQUIRY' ? '' : station,
 CATEGORY: type === 'GENERAL_INQUIRY' ? station : '',
 DESCRIPTION: desc,
 LOCATION: loc,
 CONTRACT_ACC_NO: accNo,
 PHOTOS: photo
};
var resourceRequest = new WLResourceRequest(
 '/adapters/Report/makeReport',
 WLResourceRequest.POST
);
// Remove the query parameter line, replace with request body setup
resourceRequest.setHeader('Content-Type', 'application/json');
resourceRequest.setRequestBody({ params: [invocationData] });
console.log(resourceRequest);
resourceRequest.send().then(
 response => {
 alert('return');
 this.content = response.responseJSON;
 console.log( 'Report make report====>>>>' + JSON.stringify(this.content) );
 deferred.resolve(this.content);
 alert('Success');
 },
 function(error) {
 console.log('error message' + JSON.stringify(error));
 deferred.reject(error);
 }
);

Key Changes:

  1. Removed resourceRequest.setQueryParameter('params', [invocationData]); — this was the source of the URL bloat.
  2. Added resourceRequest.setHeader('Content-Type', 'application/json'); to ensure the adapter correctly parses the request body.
  3. Added resourceRequest.setRequestBody({ params: [invocationData] }); — this mirrors how MFP 7.1 sends parameters, putting the data in the POST body where it belongs.

Additional Notes

  • If you still run into issues with very large images, you might need to check your server's configuration for maximum request body size (though you mentioned the server hasn't changed, so this is likely unnecessary unless your images are significantly larger than before).
  • This change aligns your MFP 8 request behavior with the working MFP 7.1 implementation, so it should resolve the 414 error immediately.

内容的提问来源于stack exchange,提问作者roslan armina

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.13 09:19:09