如何在 mobilefirst 8.0 中使用 Post 方法传递参数,以便 javascript API 在服务器上上传图片

How to pass parameter using Post method in mobilefirst 8.0 for javascript API to upload image on server

我尝试通过post方法将图像发送到后端,因为get方法不支持长uri。我不知道如何将参数传递给适配器。我首先使用 mfp7.1 mobile 成功传递了参数,但对于 mobilefirst 8.0,我需要使用不同的方法,即 post 方法。谁能给我解释一下

    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
  );
 request.sendFormParameters(invocationData).then(
function(response) {
    // success flow
},
function(error) {
    // fail flow
}
);

Javascript 适配器

function invokeBackend(args, proc){
WL.Logger.info("Invoking Backend procedure " + proc);
WL.Logger.info(args);

var path = "SEB-Middleware/api/" + proc;
var input = {
        method : 'post',
        returnedContentType : 'json',
        path : path,
        body : {
            contentType:"application/json; charset=UTF-8",
            content: JSON.stringify(args)
        }
    };

var response = WL.Server.invokeHttp(input);
if(response &&
        (response['isSuccessful'] && response.isSuccessful) && 
        (response['statusCode'] && response.statusCode == 200)){
    return response;
}else{
    WL.Logger.warn("Invocation Error: " + proc);
    var locale = 'en';
    if(args && args['LOCALE']) locale = args.LOCALE;

    var resp = null;
    if(response['statusCode']){
        resp =  com.seb.mfp.utility.ResponseUtil.getErrorResponse(response.statusCode, locale);
    }else{
        resp = com.seb.mfp.utility.ResponseUtil.getErrorResponse(locale);
    }

    WL.Logger.warn(resp);

    return resp;
}
 }

我收到无法从控制台读取未定义的 属性 'sendFormParameters'。如何使用我当前的 json

传递参数

您提到的错误信息是:

Cannot read property 'sendFormParameters' of undefined 

我在你的代码中看到了这个:

var resourceRequest = new WLResourceRequest(
    '/adapters/Report/makeReport',
    WLResourceRequest.POST
  );
 request.sendFormParameters(invocationData).then(

这需要更正为:

var resourceRequest = new WLResourceRequest(
    '/adapters/Report/makeReport',
    WLResourceRequest.POST
  );
 resourceRequest.sendFormParameters(invocationData).then(