HarmonyOS 鸿蒙Next 使用http接口通过POST提交数据到服务器但服务器接收不到数据,而GET正常的原因
HarmonyOS 鸿蒙Next 使用http接口通过POST提交数据到服务器但服务器接收不到数据,而GET正常的原因

日志如下:
10-08 15:40:32.454 3116-3116/com.xy375.home I 02811/StandardizedEventProcessor: Find no registered StandardizedEventHandle. 10-08 15:40:32.455 3116-3116/com.xy375.home I 02D03/HiTraceC: [eb05e529706f1b8, 0, 0] HiTraceBegin name:dispatchTouchEvent flags:1. 10-08 15:40:32.455 3116-3116/com.xy375.home E 01400/AGPWindow: [eb05e529706f1b8, 0, 0] dispatchTouchEvent not find mEngine. 10-08 15:40:32.455 3116-3116/com.xy375.home I 02D03/HiTraceC: [eb05e529706f1b8, 0, 0] HiTraceEnd. 10-08 15:40:32.458 3116-3116/com.xy375.home I 03910/Ace: AceNativeViewOhos: <private> 10-08 15:40:32.460 3116-3273/com.xy375.home I 03900/Ace: [click_recognizer.cpp(InitGlobalValue)-(2)] Unrecognized input source type: 0 10-08 15:40:32.460 3116-3273/com.xy375.home I 03900/Ace: [click_recognizer.cpp(InitGlobalValue)-(2)] Unrecognized input source type: 0 10-08 15:40:32.570 3116-3116/com.xy375.home I 02811/StandardizedEventProcessor: Find no registered StandardizedEventHandle. 10-08 15:40:32.570 3116-3116/com.xy375.home I 02D03/HiTraceC: [eb05e629708b608, 0, 0] HiTraceBegin name:dispatchTouchEvent flags:1. 10-08 15:40:32.571 3116-3116/com.xy375.home E 01400/AGPWindow: [eb05e629708b608, 0, 0] dispatchTouchEvent not find mEngine. 10-08 15:40:32.571 3116-3116/com.xy375.home I 02D03/HiTraceC: [eb05e629708b608, 0, 0] HiTraceEnd. 10-08 15:40:32.573 3116-3116/com.xy375.home I 03910/Ace: AceNativeViewOhos: <private> 10-08 15:40:32.574 3116-3273/com.xy375.home I 03900/Ace: [click_recognizer.cpp(InitGlobalValue)-(2)] Unrecognized input source type: 0 10-08 15:40:32.574 3116-3273/com.xy375.home I 03900/Ace: [click_recognizer.cpp(InitGlobalValue)-(2)] Unrecognized input source type: 0 10-08 15:40:32.574 3116-3273/com.xy375.home I 03900/Ace: [click_recognizer.cpp(HandleTouchUpEvent)-(2)] this gesture is click, try to accept it 10-08 15:40:32.574 3116-3273/com.xy375.home I 03900/Ace: [click_recognizer.cpp(OnAccepted)-(2)] Click gesture has been accepted! 10-08 15:40:32.575 3116-3273/com.xy375.home I 03900/Ace: [click_recognizer.cpp(InitGlobalValue)-(2)] Unrecognized input source type: 0 10-08 15:40:32.575 3116-3273/com.xy375.home I 03900/Ace: [click_recognizer.cpp(HandleTouchUpEvent)-(2)] this gesture is click, try to accept it 10-08 15:40:32.575 3116-3273/com.xy375.home I 03900/Ace: [gesture_referee.cpp(HandleAcceptDisposal)-(2)] gesture referee accept ClickRecognizer of id 0 10-08 15:40:32.575 3116-3273/com.xy375.home I 03900/Ace: [click_recognizer.cpp(OnAccepted)-(2)] Click gesture has been accepted! 10-08 15:40:32.576 3116-3273/com.xy375.home I 03900/Ace: [jsi_declarative_group_js_bridge.cpp(ProcessJsRequestSync)-(2)] send message, groupName:<private> functionName:<private> 10-08 15:40:32.577 3116-3273/com.xy375.home I 015B0/HttpPlugin: HttpPlugin::register. 10-08 15:40:32.577 3116-3273/com.xy375.home I 015B0/HttpPlugin: onRegister 10-08 15:40:32.579 3116-3273/com.xy375.home I 03910/Ace: PluginHandlersManager: <private> 10-08 15:40:32.580 3116-3273/com.xy375.home I chatty : uid=10664(com.xy375.home) 2.ui identical 1 line 10-08 15:40:32.582 3116-3273/com.xy375.home I 03910/Ace: PluginHandlersManager: <private> 10-08 15:40:32.585 3116-3273/com.xy375.home I 03910/Ace: Plugin#AceModuleGroup/Http: <private> 10-08 15:40:32.585 3116-3273/com.xy375.home I 015B0/HttpPlugin: into createHttpRequest 10-08 15:40:32.586 3116-3273/com.xy375.home E 03900/Ace: [plugin_jni.cpp(HandlePlatformMessageSync)-(2)] receive null result from Java 10-08 15:40:32.587 3116-3273/com.xy375.home W 03900/Ace: [byte_buffer_operator.h(ReadValue)-(2)] Exceed buffer size, readPos = 0, buffer size = 0 10-08 15:40:32.587 3116-3273/com.xy375.home W 03900/Ace: [standard_codec_buffer_operator.cpp(ReadData)-(2)] Read type failed 10-08 15:40:32.587 3116-3273/com.xy375.home W 03900/Ace: [standard_function_codec.cpp(DecodePlatformMessage)-(2)] Decode platform message failed 10-08 15:40:32.587 3116-3273/com.xy375.home I 03B00/JSApp: app Log: HttpPlugin#: js on api type: headersReceive 10-08 15:40:32.587 3116-3273/com.xy375.home I 03900/Ace: [jsi_declarative_group_js_bridge.cpp(ProcessJsRequest)-(2)] send message, groupName:<private> functionName:<private> callbackId:<private> 10-08 15:40:32.587 3116-3273/com.xy375.home I 03900/Ace: [jsi_declarative_group_js_bridge.cpp(SetEventGroupCallBackFuncs)-(2)] record event callback, requestId:<private>, callbackId:<private> 10-08 15:40:32.588 3116-3273/com.xy375.home I 03900/Ace: [jsi_declarative_group_js_bridge.cpp(ProcessJsRequest)-(2)] send message, groupName:<private> functionName:<private> callbackId:<private> 10-08 15:40:32.591 3116-3263/com.xy375.home I 03910/Ace: Plugin#AceEventGroup/Http: <private> 10-08 15:40:32.592 3116-3263/com.xy375.home I 015B0/HttpPlugin: into onSubscribe 10-08 15:40:32.592 3116-3263/com.xy375.home I 015B0/HttpPlugin: index: 0 not contains notifier, add type: headersReceive 10-08 15:40:32.596 3116-3270/com.xy375.home I 03910/Ace: Plugin#AceModuleGroup/Http: <private> 10-08 15:40:32.599 3116-3263/com.xy375.home I 03910/Ace: PluginHandlersManager: <private> 10-08 15:40:32.601 3116-3270/com.xy375.home I 015B0/HttpPlugin: into request, url = http://xx.xxx.cn:8080photo/sign/ 10-08 15:40:32.644 3116-3589/com.xy375.home I 015B0/HttpRequestUtils: set doOutPut property! 10-08 15:40:32.841 3116-3589/com.xy375.home I 015B0/HttpRequestImpl: callback http header. 10-08 15:40:32.842 3116-3589/com.xy375.home I 015B0/HttpPlugin: into onHeaderResponse, index: 0 10-08 15:40:32.843 3116-3589/com.xy375.home I 015B0/HttpPlugin: listening return. index: 0 10-08 15:40:32.843 3116-3589/com.xy375.home I 015B0/HttpPlugin: onheadersReceive trigger 10-08 15:40:32.848 3116-3273/com.xy375.home I 03B00/JSApp: app Log: header: null 10-08 15:40:32.850 3116-3589/com.xy375.home I 015B0/HttpPlugin: into onResponse, index: 0 10-08 15:40:32.852 3116-3589/com.xy375.home I 03910/Ace: PluginHandlersManager: <private> 10-08 15:40:32.852 3116-3273/com.xy375.home I 03B00/JSApp: app Log: GroupMessenger parse json result 10-08 15:40:32.853 3116-3273/com.xy375.home I 03B00/JSApp: app Log: Result:{“inf”:“123”,“y”:true} //就是没有提交上去的数据 并且确定 tel 和pass 是有值上传的 10-08 15:40:32.853 3116-3273/com.xy375.home I 03B00/JSApp: app Log: code:200 10-08 15:40:32.853 3116-3273/com.xy375.home I 03B00/JSApp: app Log: header:{“Connection”:[“Keep-Alive”],“Content-Length”:[“56”],“Content-Type”:[“application/json”],“Cross-Origin-Opener-Policy”:[“same-origin”],“Date”:[“Sat, 08 Oct 2022 07:40:33 GMT”],“Keep-Alive”:[“timeout=5, max=100”],“Referrer-Policy”:[“same-origin”],“Server”:[“nginx/1.20.2”],“Status-Line”:[“HTTP/1.1 200 OK”],“X-Content-Type-Options”:[“nosniff”],“X-Frame-Options”:[“DENY”]} 10-08 15:40:32.956 3116-3131/com.xy375.home I com.xy375.home: Compiler allocated 4767KB to compile void android.view.ViewRootImpl.performTraversals() 10-08 15:40:51.716 3116-3116/com.xy375.home I WindowManager: trimMemory level: 5 10-08 15:41:00.704 3116-3141/com.xy375.home I OpenGLRenderer: gpu complete fence is not signaled
更多关于HarmonyOS 鸿蒙Next 使用http接口通过POST提交数据到服务器但服务器接收不到数据,而GET正常的原因的实战教程也可以访问 https://www.itying.com/category-93-b0.html
"Content-Type": "application/x-www-form-urlencoded",
请求参数:
extraData:{key:value}
试一下,这个应该是可以的,测试是通过的。
"Content-Type": "application/x-www-form-urlencoded",
header:{
"Content-Type": "application/x-www-form-urlencoded",
},
更多关于HarmonyOS 鸿蒙Next 使用http接口通过POST提交数据到服务器但服务器接收不到数据,而GET正常的原因的实战系列教程也可以访问 https://www.itying.com/category-93-b0.html
这个 可以 json 的就是不行,
HarmonyOS 鸿蒙Next 使用 HTTP 接口通过 POST 提交数据到服务器但服务器接收不到数据,而 GET 请求正常,可能的原因如下:
-
请求头设置不当:POST 请求通常需要设置正确的
Content-Type
请求头,以指明发送数据的格式(如application/json
,application/x-www-form-urlencoded
等)。如果未设置或设置错误,服务器可能无法正确解析数据。 -
数据格式错误:POST 请求的数据格式需与
Content-Type
对应。例如,若Content-Type
为application/json
,则数据应为 JSON 格式。格式错误或编码问题可能导致服务器无法解析。 -
服务器端配置问题:服务器可能配置了特定的中间件或路由规则,对 POST 请求有额外的处理逻辑或限制,导致数据未被正确接收。
-
网络或代理问题:在某些网络环境下,POST 请求可能受到代理服务器、防火墙等设备的限制或修改,导致数据丢失或格式变化。
-
客户端实现问题:鸿蒙客户端在发送 POST 请求时可能存在实现上的缺陷,如数据未正确封装、连接未正确关闭等。
请检查上述方面,确保客户端请求正确无误,并与服务器端开发人员确认服务器配置及日志,以定位问题。如果问题依旧没法解决请联系官网客服,官网地址是 https://www.itying.com/category-93-b0.html,