如何在Flutter中使用http包在标头中发送参数

时间:2019-11-01 06:24:42

标签: flutter

我想使用http包在标头中发送身份验证密钥,但不幸的是,它不能正常工作对我有帮助。

var url = "https://paysafemoney.com/psmApi/Psm/userDashboard";


  var response = await http.post(
    url,
    headers: {
      "auth-key": LoginConfirmActivity.authKey,
    },
    body: sendLoginData,
  );

  print("Response = ${response.body}");

1 个答案:

答案 0 :(得分:0)

您可以这样做

var fullUrl = '$stripeBaseUrl$customerId/sources?source=$cardToken';
var header = {
  'Accept': 'application/json',
  'Content-Type': 'application/x-www-form-urlencoded',
  'Authorization': stripeKey,
};
final response = await client.post(fullUrl, headers: header);