标题和正文颤动的发布请求

时间:2019-08-11 09:33:53

标签: flutter

任何人都可以帮助我为下面的标头和正文写扑打请求,并在下面提供相应的响应;

示例发帖请求

标题请求:

Content-Type:application/x-www-form-urlencoded

身体要求:

grant_type: client_credentials

scope: accounts

client_assertion_type: code**

client_assertion: code**

1 个答案:

答案 0 :(得分:1)

尝试以下操作,

String hostname = "myhostname";// example
String port = "1234"; //example
String url = "https://$hostname:$port/as/token.oauth2";
String body = "{'grant_type' : '$client_credentials' }" +
              "'scope' : '$accounts'" +
              //... etc etc 
              "'Corresponding Response': { 'access_token': 'JWt CODE', 'expires_in': '86400', 'token_type': 'bearer', 'scope': 'payments' }"+
             "}";
var res = await http.post(Uri.encodeFull(url),
        headers: {
          "Accept": "application/json",
          "Content-Type" : "application/x-www-form-urlencoded"
        },
        body: body);