• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

[SOLVED] Http Post returns status -1 while http_status is 200

W

Wheel7Games

Guest
I am creating a .NET Core Web Api highscore server. The server side is working nicely when I use Postman to test the Api. When I started testing the Api from my GMS game, I got an error.

When I debug the async call, I notice that the status has a value of -1. However, when I check the http_status, I see the code is 200, like it's supposed to be. Any idea why the status is -1 while the http_status is 200? Shouldn't it be 1?

The highscore has correctly been processed by the server btw

I have been using the http_controller in this wonderful example btw.
https://www.yoyogames.com/blog/522/...controller?utm_source=email&utm_campaign=blog
 

FrostyCat

Redemption Seeker
Show your actual code, the debug result (including response) and the exact version of GM you're using.
 
W

Wheel7Games

Guest
I'm using the latest version (2.2.2).

I have compiled a demo application, which connects to my demo api. You can download it here. Any help is greatly appreciated.
 
H

Homunculus

Guest
You’re not going to get much help by posting the compiled project. You need to provide the relevant code and details about the response you get
 
W

Wheel7Games

Guest
By compiled I meant that I made a zip file with an entire GMS project, which can be downloaded, executed and debugged :p

Compiled as in put together. Not as in, I made an executable.
 
Last edited by a moderator:
W

Wheel7Games

Guest
I just found the issue. I forgot to include the payload in the Ok response (200).

When there is no data in the response, GML is returning -1. Apparently, GML needs a response after a POST, which makes sense. Otherwise you should send NoContent (204).

  • A 200 response always has a payload, though an origin server MAY generate a payload body of zero length or empty payload.
And I should actually return a 201 (Created), since I am adding score.
 
Last edited by a moderator:
Top