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

Discussion in 'Programming' started by Wheel7Games, Jun 16, 2019.

  1. Wheel7Games

    Wheel7Games Member

    Joined:
    Nov 6, 2017
    Posts:
    9
    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
     
  2. FrostyCat

    FrostyCat Member

    Joined:
    Jun 26, 2016
    Posts:
    4,156
    Show your actual code, the debug result (including response) and the exact version of GM you're using.
     
  3. Wheel7Games

    Wheel7Games Member

    Joined:
    Nov 6, 2017
    Posts:
    9
    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.
     
  4. Catan

    Catan Member

    Joined:
    Jun 20, 2016
    Posts:
    616
    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
     
  5. Wheel7Games

    Wheel7Games Member

    Joined:
    Nov 6, 2017
    Posts:
    9
    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: Jun 17, 2019
  6. Wheel7Games

    Wheel7Games Member

    Joined:
    Nov 6, 2017
    Posts:
    9
    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: Jun 17, 2019
    makas likes this.

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice