简体   繁体   English

如何在 Flutter 中设置“X-IW-SESSION”的属性

[英]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.

相关问题 如何设置跨域会话 - how to set cross domain session 如何在MongoDB函数中设置一个http session cookies? - How to set a http session cookies in MongoDB functions? Symfony 2:如何在登录时设置会话生命周期? - Symfony 2: How to set the session lifetime at login? 如何将API(令牌)身份验证的用户(在Flutter应用中)重定向到基于会话的身份验证(在Flutter Web视图中)? - How to redirect an api (token) authenticated user (in a flutter app) to session based auth (in a flutter web view)? 如何增加Cakephp 3.x中的Auth会话过期时间? - How to increase Auth session expire time in Cakephp 3.x? 如何在JS和PHP API之间设置会话令牌? - How to set up session token between JS and PHP API? 如何从谷歌应用程序脚本设置会话 cookie - How to set a session cookie from google app script 如何在会话超时时在Django Admin中设置自定义管理员登录URL? - How to set custom admin login URL in Django Admin on session timeout? 如何通过Java API在Keycloak中设置自定义用户属性 - How to set Custom User Property in keycloak from java api 使用柏树在 window 上设置属性 - Set a property on window with cypress
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM