How do I create and send a json POST request to a URL?

0 favourites
  • 4 posts
From the Asset Store
Awardkit
$5 USD
Create custom awards and achievement or use the many templates and create your own.
  • Hello,

    I'm very new to Construct 2, but I'm an experienced programmer. I'm researching Construct 2 because I have an aversion to JavaScript, but I need to make a commercial web game for a business.

    I'm trying to learn how one might use Construct 2's interface to dynamically build a json string containing variables from a game session, send it to a URL, receive a json response, and access the content of the json.

    In Unity and Unreal Engine, this is a piece of cake, but those engines are too heavy for my needs, and their HTML5/JS export is still very experimental. (Plus, ya know, royalties).

    Say for instance I have a login page, with two fields: Username, Password. The user fills these in. How would I go about plugging those values into a json string, to end up with this?

    {
        login : {
            username : "abc",
            password : "123"
        }
    }
    [/code:27x0e3bh]
    
    And once I have that, I need to send it to my server and receive the json response containing an authentication token, which will be used for all subsequent requests.
    
    I will need to know if the request succeeded/failed and any associated error codes as well.
    
    Is this possible in the current version of Construct 2?
    
    Thanks.
  • I dont worked with ajax like this, but I would try it like one of these examples. Not tested!

    Problem with this examples, my Tools plugin is also very experimental.

    But I think there are other stable plugins for json... Search...

  • Thanks for the response. I will do some research into the AJAX object and try to find any simple JSON plugins.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • I find mine most simple and flexible, but I think because I know every function.

    It's just not completly done yet and I adjust to my project if needed.

    I cant explain it, because Im not good in and my bad english... But that you see in description.

    Actually, we do almost the same.

    The only difference, my server is Smartfox.

    I have to work with quite large json, with 10+ entrys and deep of 5+, like "params.characters[0].look.hair.color" as one entry.

    Exactly for this I build my plugin.

    With the other json plugins I have found, I had problems.

    If you find a good one to handle json in/output, let me know...

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)