C#C
C#2y ago
132 replies
SylveonDeko

Im getting a very ambiguous error when trying to get data via aspnet

the error;

{
    "type": "https://tools.ietf.org/html/rfc9110#section-15.5.1",
    "title": "One or more validation errors occurred.",
    "status": 400,
    "errors": {
        "$": [
            "The input does not contain any JSON tokens. Expected the input to start with a valid JSON token, when isFinalBlock is true. Path: $ | LineNumber: 0 | BytePositionInLine: 0."
        ],
        "model": [
            "The model field is required."
        ]
    },
    "traceId": "00-553b2b7da84c52f6ab86d008eb76943f-adb629679e4bd9de-00"
}


The code:
 /// <summary>
    /// Updates a guild config from the provided json and guildid
    /// </summary>
    /// <param name="guildId">The guildid to update a config for</param>
    /// <param name="model">The json body of the model to update</param>
    /// <returns></returns>
    [HttpPost]
    public async Task<IActionResult> UpdateGuildConfig(ulong guildId, [FromBody] GuildConfig model)
    {
        try
        {
            if (!ModelState.IsValid)
                return BadRequest(ModelState);
            await service.UpdateGuildConfig(guildId, model);
            return Ok();
        }
        catch (Exception e)
        {
            Log.Error(e, "Error updating guild config");
            return StatusCode(500);
        }
    }
}
Was this page helpful?