本文介绍了“多部分主体必须具有至少一部分".的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在上一个问题中(在Android上反应本地上传图片)用参数"FormData"描述了请求,但是我请求了不带数据的GET请求,并得到了相同的消息!
In previous asked question (react-native upload pictures on android) described request with param "FormData", but I requested GET request without data and got same message!
启用了ProGuard的本地本机应用程序= true
react-native app with ProGuard enabled = true
应用程序在首次请求时崩溃.
App crashed on first request.
06-16 14:00:30.971: E/AndroidRuntime(14321): java.lang.IllegalStateException: Multipart body must have at least one part.
06-16 14:00:30.971: E/AndroidRuntime(14321): at okhttp3.MultipartBody$Builder.build(SourceFile:327)
06-16 14:00:30.971: E/AndroidRuntime(14321): at com.facebook.react.modules.network.NetworkingModule.sendRequest(SourceFile:309)
06-16 14:00:30.971: E/AndroidRuntime(14321): at java.lang.reflect.Method.invoke(Native Method)
06-16 14:00:30.971: E/AndroidRuntime(14321): at java.lang.reflect.Method.invoke(Method.java:372)
06-16 14:00:30.971: E/AndroidRuntime(14321): at com.facebook.react.bridge.BaseJavaModule$b.a(SourceFile:345)
06-16 14:00:30.971: E/AndroidRuntime(14321): at com.facebook.react.cxxbridge.JavaModuleWrapper.invoke(SourceFile:136)
06-16 14:00:30.971: E/AndroidRuntime(14321): at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method)
06-16 14:00:30.971: E/AndroidRuntime(14321): at android.os.Handler.handleCallback(Handler.java:739)
06-16 14:00:30.971: E/AndroidRuntime(14321): at android.os.Handler.dispatchMessage(Handler.java:95)
06-16 14:00:30.971: E/AndroidRuntime(14321): at com.facebook.react.bridge.queue.a.dispatchMessage(SourceFile:31)
06-16 14:00:30.971: E/AndroidRuntime(14321): at android.os.Looper.loop(Looper.java:135)
06-16 14:00:30.971: E/AndroidRuntime(14321): at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(SourceFile:196)
06-16 14:00:30.971: E/AndroidRuntime(14321): at java.lang.Thread.run(Thread.java:818)
更新:这是错误的部分,其中this._query
是空对象:
Update: Here is wrong part, where this._query
was empty object:
let fd = new FormData;
forEach(this._query, (value, key) => {
fd.append(key, value)
});
params.body = fd;
推荐答案
我试图将正文传递为空的 FormData ,所以有关身体的信息不包含任何内容.
I tried to pass body as empty FormData, so message about body without any part of it.
这篇关于“多部分主体必须具有至少一部分".的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!