1
在前面的問題(react-native upload pictures on android)與param「FormData」描述請求,但我請求沒有數據的GET請求,並得到相同的消息!「多部分主體必須至少有一個部分」
使用ProGuard反應本地應用啓用=真
應用墜毀在第一請求。
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
是空的對象:
let fd = new FormData;
forEach(this._query, (value, key) => {
fd.append(key, value)
});
params.body = fd;