Im getting a very ambiguous error when trying to get data via aspnet
the error;
The code:
79 Replies
The json im sending as the body
https://paste.mod.gg/dnngsmodvzpw/0
BlazeBin - dnngsmodvzpw
A tool for sharing your source code with the world!
:foxexited:
what a beefy json
maybe the error is in the sender, not in the receiver
which is what im trying to find out
im actually gonnago insane
well, that's fair, it's not valid json
also, where is
guildId
configured
[HttpPost] public async Task<IActionResult> UpdateGuildConfig(ulong guildId, [FromBody] GuildConfig model)like, the route
At the controller class
I’ve tried with valid json too
what do you mean, you've put this in parameter in the routing attribute of the class itself?
Correct
Also I solved this, at least for afk, somehow removing the required attribute fixed it
yes, removing required "fixes" it but
uhm i was sure i wrote another message
what is happening
was it another thread?
i remember saying that some tests could be useful
this issue has reappeared
but this time it doesnt even make sense
the response i send:
The controller code:
The response:
I am actually going to go insane
and yes, i have tried doing {"commandName": "test"} too
How are you sending that data?
Does it work when sending with Swagger or some API client like Bruno or Insomnium?
Tried with postman and swagger, no go
That’s why im stumped, I would expect at least swagger to be able to do it
Try wrapping the parameter into a record or something?
Tried that, then it says it requires that, even if I provide the correct json for it
What do the logs and the debugger say? Is it this action that get's hit?
It is yeah, it returns a 400, the body gets received
have you tried just deserializing the model calling stj deserialize directly?
Model or just a string it does the same thing, it doesn’t get to the content of the controller at all
heres what logs say, route gets matched just fine
i added te request received and body to the logs
What's the content-type of the request?
application/json
now the funny thing is, i have a post request structured in the exact same way
it works fine
this delete request doesnt
Hmmm, are they both in the same controller?
yep
:ThinkingRot:
$$paste
$paste
If your code is too long, you can post to https://paste.mod.gg/, save, and copy the link into chat for others to see your shared code!
BlazeBin - ackfvzwsxxkp
A tool for sharing your source code with the world!
i am incredibly confused
So not even
"{"commandName": "test"}"
work?correct
:huh:
now heres something funny
and its what drove me the most insane
doing this works, but i dont want this to be the solution
im about ready to go to a mental institution
this post method was working yesterday
i have changed nothing
Hmmm, actually
{"commandName": "test"}
should not work, because {"commandName": "test"}
means there should be a model to bind toyeah, this should work
but now
look at my post method from here
:ASthink:
its like its gaslighting me
I mean...it's working on my end :Kek:
i swear to god if this is some weird linux shit
same thing happens on my linux server
the entire api is doing it now 💀
i am extremely confused
:megaweird:
$paste
If your code is too long, you can post to https://paste.mod.gg/, save, and copy the link into chat for others to see your shared code!
see if theres something wrong weith my program.cs
https://paste.mod.gg/smdhaqrxnmct/1
BlazeBin - smdhaqrxnmct
A tool for sharing your source code with the world!
GitHub
Mewdeko/src/Mewdeko/Program.cs at psqldeko · SylveonDeko/Mewdeko
Mewdeko. Contribute to SylveonDeko/Mewdeko development by creating an account on GitHub.
LGTM, nothing there should cause any problems
right
but there are problems and its driving me up the damn wall
Does the serialization error also happen when sending
"test"
from postman?yes
Okay what happens if you remove commandName entirely
e
well then it goes through, if i make it part of the route it goes through
I know it's a weird question, is your keyboard langauge "EN"?
im on net8 btw, lang ver 12
yes
Okay, can you try making a request using cURL?
sure
same error lel
....
so on a hunch
i commented out my request logger
which i added for debugging
and the post request goes through
// app.Use(async (context, next) =>
// {
// var logger = context.RequestServices.GetRequiredService<ILogger<Mewdeko>>();
// logger.LogInformation($"Request received: {context.Request.Method} {context.Request.Path}");
// logger.LogInformation($"Request body: {await new StreamReader(context.Request.Body).ReadToEndAsync()}");
// await next();
// });
i only uncommented it because the delete request wasnt working
:Bruh:
Hmmm
Can you try escaping
"
in the body?
(for curl)no no, that is the expected output
what it did just now
Ik
something here is causing the json to get lost
But it's still not working for the DELETE endpoint right 😅 ?
sec
Also
I think the body is only allowed to be read once
yeah thats what i was thinking
it works now
:Bruh:
i am so god damn confused right now
Wait
Even with the logger?
no the logger is disabled
Yeah
Makes sense
but heres the thing
i only enabled the logger because i was getting a 403
no sorry 400
:huh:
In the DELETE endpoint?
anyway, it works now
yeah
If it works it works
:Shruge:
yeah lmao
noo-ooo
the controller maybe is not the issue
analyze this thing giving the string to STJ.Deserialize<>