How to Pass Json Data to Web Server

My project has different web services and within few web services, web developer asking for JSON data to pass from mobile device.

This kind of data I have to pass for web service:

const Game = sequelize.define('games', {
    game_ts: { type: DataTypes.STRING },
    gameid: { type: DataTypes.STRING },
    user_id: { type: DataTypes.STRING },
    object_name: { type: DataTypes.STRING },
    is_win: { type: DataTypes.INTEGER },
    user_skill: { type: DataTypes.STRING },
    game_results: { type: DataTypes.JSON },
    level: { type: DataTypes.JSON },
    balance: { type: DataTypes.JSON },
    extra_data: { type: DataTypes.JSON },
    dt: { type: DataTypes.STRING },
});

Now if you check data type of each field then its String, Integer and JSON types.

From these, regarding JSON type I was confused, up to now I was sending data like following way but it was not working:

 WWWForm form = new WWWForm();
        form.AddField(ARG_USER_ID, AdhocStorage.userProfile.userId);
        form.AddField(ARG_GAME_ID, GameManager.Instance.SelectedGameId);
        form.AddField(ARG_GAME_TIMESTAMP, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
        form.AddField(ARG_BALANCE, "{\"coin_1\": 0,\"cash_g\": 0}");
        form.AddField(ARG_LEVEL_ID, GameManager.Instance.SelectedLevelId);
        form.AddField(ARG_OBJECT_NAME, "HoopsEnglish:" + GameManager.Instance.SelectedGameId);
        form.AddField(ARG_IS_WIN, postGamePanel.IsHumanPlayerWinner() ? 1 : 0);
        form.AddField(ARG_USER_SKILL, 0);
        form.AddField(ARG_GAME_RESULTS, "{\"coin_1_spent\": 0,\"coin_1_earn\": 0,\"cash_g_spent\": 0,\"cash_g_earn\": 0,}");
        form.AddField(ARG_LEVEL, "level\": {\"main_level\": 0,\"prog2\": 0,\"prog32\": 0},");
        form.AddField(ARG_EXTRA_DATA, "{\"score\": " + GameManager.Instance.Player1TotalScore + "-" + GameManager.Instance.Player2TotalScore + ", \"time\": " + gamePlayPanel.player1GamePlayTimer + "}");
        form.AddField(ARG_LOGIN_DATE, DateTime.Now.ToString("yyyy-MM-dd"));

using (UnityWebRequest webRequest = UnityWebRequest.Post(GameConstants.HOOPSENGLISH_BASE_URL + GameConstants.WEB_SEND_GAME_STATS_URI, form))
        {
            webRequest.SetRequestHeader(HEADER_AUTHORIZATION, AdhocStorage.userProfile.accessToken);

            // Request and wait for the desired page.
            yield return webRequest.SendWebRequest();

            switch (webRequest.result)
            {
                case UnityWebRequest.Result.ConnectionError:
                case UnityWebRequest.Result.DataProcessingError:
                    Debug.LogError("Error: " + webRequest.error);
                    break;
                case UnityWebRequest.Result.ProtocolError:
                    Debug.LogError("HTTP Error: " + webRequest.error);
                    break;
                case UnityWebRequest.Result.Success:
                    Debug.Log("Received: " + webRequest.downloadHandler.text);
                    break;
            }
        }

As you are seeing in the above code, I was passing data either in integer or string.

What is the correct way to pass data for JSON field?

Gotta figure out why it’s not working first before you can even consider fixing it.

Networking, UnityWebRequest, WWW, Postman, curl, WebAPI, etc:

https://discussions.unity.com/t/831681/2

https://discussions.unity.com/t/837672/2

And setting up a proxy can be very helpful too, in order to compare traffic:

https://support.unity.com/hc/en-us/articles/115002917683-Using-Charles-Proxy-with-Unity