0

I just want to call simple API but can't able to call. If I tried to call in Postman then get proper response.

Look at my code

Future<AppServiceModel> getAllItems({String pageID = ""}) async {
    final String _url = "http://www.textsite.com/api/app-view?page_id=";

    final finalURL = Uri.encodeFull(_url);        
    try {
      return http.get(finalURL, headers: {
        HttpHeaders.contentTypeHeader: 'application/x-www-form-urlencoded',
        HttpHeaders.acceptHeader: "application/json",
        HttpHeaders.authorizationHeader: 'Bearer $accessToken'
      }).then((response) {
        Map<String, dynamic> _resDic =
            Map<String, dynamic>.from(json.decode(response.body));
        print('===>> Response : $_resDic');
        return AppServiceModel.fromJson(_resDic);
      });
    } catch (e) {
      print("Error: $e");
      return null;
    }
  }

I also tried to pass QueryParameters by following How do you add query parameters to a Dart http request?

But each time get response

Response : {code: 7, msg: Your login session has expired. Please login again to continue., data: []}

I'm damm sure, passing right TOKEN.

Below is output of Postman

enter image description here

Govaadiyo
  • 5,644
  • 9
  • 43
  • 72

0 Answers0