79670447

Date: 2025-06-18 10:31:17
Score: 0.5
Natty:
Report link

First I got "Error: Server responded with status code 403" when i tried to print the statusCode.

Adding headers like 'User-Agent' and 'Accept' helps the server accept your request and respond with the data you expect.( i told chatgpt to give me headers )

var response = await http.get(
                Uri.parse("https://jsonplaceholder.typicode.com/posts"),
                headers: {
                  'User-Agent': 'Mozilla/5.0',
                  'Accept': 'application/json',
                },
              );
Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: JIHED