[英]How to set property of 'X-IW-SESSION' in Flutter
I am converting my employer's current android app to flutter.我正在将我雇主当前的 android 应用程序转换为 flutter。 One of the difficulties I have been facing recently is how I post data to the server with json.我最近遇到的困难之一是如何使用 json 将数据发布到服务器。
For some data transactions, the server requires the 'X-IW-SESSION', which is set as follows in the original app:对于一些数据交易,服务端需要'X-IW-SESSION',在原app中设置如下:
httpURLConnection.setRequestProperty("X-IW-SESSION", session);
I've tried using the following properties, but I am unable to get the result I need.我尝试使用以下属性,但无法获得所需的结果。
Map<String, String> headers = {
HttpHeaders.contentTypeHeader: "application/json",
HttpHeaders.authorizationHeader: session,
};
I checked this over flutter's official documentation.我通过颤振的官方文档检查了这一点。 I couldn't find the name 'x-iw-session' but saw something similar = HttpHeaders.authorizationHeader
.我找不到名称 'x-iw-session' 但看到类似的东西 = HttpHeaders.authorizationHeader
。
In the old android app, the 'x-iw-session' helps the user to login using a session (String) which is stored in the shared preferences.在旧的 android 应用程序中,“x-iw-session”帮助用户使用存储在共享首选项中的 session(字符串)登录。 In the flutter app, I have access to the same session (String), but I am lost as to how should I use the same to login into the server.在 flutter 应用程序中,我可以访问相同的 session(字符串),但我不知道应该如何使用它登录服务器。
Currently, this is what my server sends as response for failure:目前,这是我的服务器作为失败响应发送的内容:
{success: false, message: Please Login..You dont have permission}
Please do tell, If I need to show some specific code.请告诉我,如果我需要显示一些特定的代码。
Maybe this would work.也许这会奏效。
Map<String, String> headers = {
HttpHeaders.contentTypeHeader: "application/json",
”X-IW-SESSION”: session,
};
If so, check for a declaration in HttpHeaders.如果是这样,请检查 HttpHeaders 中的声明。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.