Answers for "Exception has occurred. StateError (Bad state: Cannot set the body fields of a Request with content-type "application/json".)"

0

Exception has occurred. StateError (Bad state: Cannot set the body fields of a Request with content-type "application/json".)

import 'package:http/http.dart' as http;
import 'dart:convert';

Map<String,String> headers = {'Content-Type':'application/json','authorization':'Basic c3R1ZHlkb3RlOnN0dWR5ZG90ZTEyMw=='};
final msg = jsonEncode({"grant_type":"password","username":"******","password":"*****","scope":"offline_access"});

var response = await post(Urls.getToken,
               headers: headers,
               body: msg,
            );
Posted by: Guest on January-17-2021

Code answers related to "Exception has occurred. StateError (Bad state: Cannot set the body fields of a Request with content-type "application/json".)"

Code answers related to "Javascript"

Browse Popular Code Answers by Language