本文介绍了MobileFirst适配器调用失败,并带有-不支持的媒体类型错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我们有mobilefirst适配器,它在swagger工具中可以正常工作,但是当我们尝试从客户端调用不受支持的媒体类型错误代码415时,它的提供错误.
We have mobilefirst adapter its working properly in swagger tool but when we are trying to invoke from client side its giving error for unsupported media type-errorcode 415.Environment mobilefirst 8.0 with ibm cloud object storage .
server side java adapter code below like that,
-----------------------------------------
@POST
@Path("/uploadImageToObjectStorage")
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
@OAuthSecurity(enabled = false)
public String uploadImage(@QueryParam(value="imageName") String imageNameWithExtn, @QueryParam(value="imageMimeType") String imageMimeType, @FormParam(value="imageDataInBase64Str") String imageBase64String){
/// do to
}
cordova ionic 2 calling adapter or invoke adapter like that,
-------------------------------------------------------------
var resourceRequest = new WLResourceRequest("/adapters/Test/TestAdp/upload",WLResourceRequest.POST);
resourceRequest.send().then((response) => {
resourceRequest.setQueryParameter("imageName", 'store');
resourceRequest.setQueryParameter("imageMimeType",'image/png');
resourceRequest.setQueryParameter("imageDataInBase64Str",this.imageDataInBase64Str);
},
function(error){
console.log(error);
});
推荐答案
我正在使用IBM Work light实现设备令牌适配器,但出现了相同的错误:
I was implementing the device token adapter using IBM Work light and i got same error :
当我使用这个时:
request?.setHeaderValue("application/json" as NSObject, forName: "Content-Type")
解决了我的问题,请尝试这个.
Resolved my issue , try this.
这篇关于MobileFirst适配器调用失败,并带有-不支持的媒体类型错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!