0

First, I am using Windows and latest Flutter and Parse installation.

This is how I initiated Parse:

await Parse().initialize(
      "myAppId", 
      "http://192.168.1.55:4040/parse/",
      debug: true
    );

And here the code that gives the error:

      var obj = ParseObject("GameScore");
      obj.set<int>("score", 123);
      obj.set<String>("playerName", "Ahmed Hammad");
      obj.set<bool>("cheatMode", false);
      await obj.save();

and here is the detailed error I got:

I/flutter (31178): ╭-- Parse Request
I/flutter (31178): curl -X POST -H 'content-type: text/plain; charset=utf-8' -H 'user-agent: Flutter Parse SDK 4.0.2' -H 'X-Parse-Application-Id: myAppId' -d '{"score":123,"playerName":"Ahmed Hammad","cheatMode":false}' http://192.168.1.55:4040/parse/classes/GameScore
I/flutter (31178): 
I/flutter (31178):  http://192.168.1.55:4040/parse/classes/GameScore
I/flutter (31178): ╰--
I/flutter (31178): ╭-- Parse Response
I/flutter (31178): Class: GameScore
I/flutter (31178): Function: ParseApiRQ.create
I/flutter (31178): Status Code: -1
I/flutter (31178): Type: OtherCause
I/flutter (31178): Exception: FormatException: Unexpected end of input (at character 1)
I/flutter (31178): 
I/flutter (31178): ^
I/flutter (31178): 
I/flutter (31178): ╰-- 

But when I send copy/paste of the logged curl command, I got the data added successfully.

command line screenshot

Appreciate support.

Ahmed Hammad
  • 622
  • 8
  • 17

1 Answers1

0

The reason is clear now.

The curl is running through my PC, but the code above runs on my Android emulator Nexus 5X API30 and fails.

When I run same code on the Android device directly, it works.

Why Emulator fail? I found that you must user special address from the emulator: see How to connect to a local server from an android emulator?

Ahmed Hammad
  • 622
  • 8
  • 17