0

I'm trying to send a request from a site that works at http://flat.imruz.com/api/sliders and http://flat.imruz.com/api/categories В The api code works well in the browser. And when I run it on the emulator, it throws an error (FormatException: Unexpected character (at character 1)). I'll attach the flutter screenshots below.

enter image description here

enter image description here

enter image description here

enter image description here

Flutt Dev
  • 47
  • 1
  • 5

3 Answers3

1

Your API endpoint returns HTML instead of a JSON. Make sure that:

  • the endpoint URL is valid,
  • your request is valid and the API handles errors properly,
  • you've added a 'Content-type': 'application/json' header,
  • you are authorized to access the endpoint.
Karol Lisiewicz
  • 654
  • 5
  • 15
0

Check this article Flutter FormatException: Unexpected character (at character 1) And first google then create a thread. And check that https://issue.life/questions/57473788 There in Russian, but at the end there is a link not a git hub with answers

augustin
  • 1
  • 1
0

You have double slash in you final url generated

replace this

String _baseUrl = 'http://flat.imruz.com/api/';

with this

String _baseUrl = 'http://flat.imruz.com/api'
hiashutoshsingh
  • 980
  • 2
  • 14
  • 41