WebAPI returning 415 before it ever reaches a line of code in my controller...
-
How the hell do you debug such a thing?
It happened when I changed the form submission to being a Multi-Part POST instead of a normal POST. That's usually a no-op-- there's no reason WebAPI should treat the POSTed data any differently, but it is... somehow... for some reason?
This would be fine if I could debug the damned error, but it happens before any of my own code is executed.
-
415 is 'Unsupported media type', so check the request headers and your server config are correct.
Oh, and it's not WebAPI returning 415, it's IIS (or whatever server you're using. Probably IIS).
-
415 is 'Unsupported media type', so check the request headers and your server config are correct.
That is the opposite of useful.
Check WHERE? What settings? What does "correct" mean?
-
You're developing a web application, and you don't know how to check request headers or server config?
-
You're developing a web application, and you don't know how to check request headers or server config?
Of course I know how to check them. I'm looking at them right now.
What I don't know is what to check them for.
Look, stop being a dick. If you don't know the answer, just say, "I don't know." I already know you're wrong about one thing: it's entirely possible for WebAPI to return a 415 on its own, independent of IIS.
-
You have all the info you need to fix the problem; there is nothing more I can add.
And no, I'm not going to give you a crash-course in HTTP.
Maybe if you weren't allergic to Google, you wouldn't have even started this thread.
-
-
Of course I know how to check them. I'm looking at them right now.
What I don't know is what to check them for.
This is basically the water heater debacle all over again. I suggest you call a repairman, because you are obviously not qualified to do the task you are attempting to do.
I think you posted in the wrong place. You may want to try http://stackoverflow.com, another of Jeff's fine constructs.
-
You have all the info you need to fix the problem; there is nothing more I can add.
What settings in IIS can cause a 415 to be returned? That is a piece of information I do not have.
And no, I'm not going to give you a crash-course in HTTP.
I know how HTTP works. I know what 415 means. What I do not know is:
- What part of my request is incorrect, so that it could cause a 415?
- What settings in IIS/WebAPI can return a 415 to a (normally) valid request?
Maybe if you weren't allergic to Google, you wouldn't have even started this thread.
I started this thread after looking for the problem on Google; the solutions I found there do not apply to my situation.
popcorn
Fuck off you piece of shit. This is the serious part of the site, I'm asking for help.
This is basically the water heater debacle all over again. I suggest you call a repairman, because you are obviously not qualified to do the task you are attempting to do.
Fuck off you piece of shit. This is the serious part of the site, I'm asking for help.
-
Fuck off you piece of shit. This is the serious part of the site, I'm asking
for helpto be spoon fed the answer, when I would trash talk anyone else who did the same.FTFY
-
I know how HTTP works. I know what 415 means. What I do not know is:
- What part of my request is incorrect, so that it could cause a 415?
- What settings in IIS/WebAPI can return a 415 to a (normally) valid request?
- Funnily enough, it might have something to do with the media type specified in the request. But then how can I tell? You haven't posted the request headers.
- Just pulling this out of my arse, but maybe it's something to do with media types. But how can I tell? You haven't posted the server config.
You know about MIME types, yes?
-
1) Funnily enough, it might have something to do with the media type specified in the request. But then how can I tell? You haven't posted the request headers.
They're fine.
2) Just pulling this out of my arse, but maybe it's something to do with media types. But how can I tell? You haven't posted the server config.
They're fine.
You know about MIME types, yes?
Yes. Now go away. Nothing you've said has helped even a tiny iota; you obviously have no fucking clue what you're talking about.
The problem seems to be that WebAPI doesn't ship with a multipart/form-data formatter by default. I'm stumped as to why, but switching the request to use a Content-Type WebAPI does set a formatter for (for example, application/json) causes the request to enter my controller.
So now the exercise is to either find or write a formatter for multipart/form-data
-
Fuck off you piece of shit. This is the serious part of the site, I'm asking for help.
asking for help is generally a lot more polite.
we have next to no information about what request you are sending and what app is receiving it. it cannot be a surprise we have little to no help to provide.
-
FTFY
This is Coding Help. I wouldn't trash talk anybody who posted here. I would hope that nobody else would, either. But apparently I am wrong.
-
This is Coding Help. I wouldn't trash talk anybody who posted here. I would hope that nobody else would, either. But apparently I am wrong.
Just you. I will leave you alone now. You are sufficiently rankled.
-
Yes. Now go away. Nothing you've said has helped even a tiny iota; you obviously have no fucking clue what you're talking about.
Right, so because you gave no info at all, I'm the one at fault.Y'know what, I'm sick of your shit. I try to help you, and you treat me like garbage. So next time you want help, just fuck off, because you won't get a damn thing from me.
-
It happened when I changed the form submission to being a Multi-Part POST instead of a normal POST. That's usually a no-op-- there's no reason WebAPI should treat the POSTed data any differently, but it is... somehow... for some reason?
FWIW, I remember having an issue with JSPs and not being able to do the same stuff with a multipart/form-data vs a standard form post. Probably not helpful, but I think they're handled completely differently (Something like getParamater() stopped working, and us having to parse the stream with the multipart manually...) I don't know anything about WebAPI, but it might be the same issue.
EDIT:
@blakeyrat said:The problem seems to be that WebAPI doesn't ship with a multipart/form-data formatter by default. I'm stumped as to why, but switching the request to use a Content-Type WebAPI does set a formatter for (for example, application/json) causes the request to enter my controller.
So now the exercise is to either find or write a formatter for multipart/form-data
Yep, that's what we had to do
-
Right, so because you gave no info at all, I'm the one at fault.
-
if you can't help me, don't post at all. If you needed more information to help me, post and ask for it. You did neither.
-
the first post does contain all the information you need to identify the problem, which is that WebAPI does not support multipart/form-data by default.
-
you were DEAD WRONG when you said the error was returned by IIS, and led me in the wrong direction for a time.
Now that I've narrowed down the problem here, I'm hoping this article will be useful in solving it:
-
-
Now, just copy and paste that like a good little programmer.
-
1) if you can't help me, don't post at all. If you needed more information to help me, post and ask for it. You did neither.
@RaceProUK said:You haven't posted the request headers.
@RaceProUK said:You haven't posted the server config.
It's almost as if I wanted to see those things...
2) the first post does contain all the information you need to identify the problem, which is that WebAPI does not support multipart/form-data by default.
You said you were getting a 415 from a multipart post, and that was all. That could have been anything from a missing WebAPI module/parser/thing to a spelling error in the header. But to know for sure, I would have needed to see the request headers. Which I (indirectly) asked for.
I work with someone almost as obtuse as you; frequently, he would have a go at me for not providing enough info. So, you want to know how I dealt with that?
I started providing more info.
Funnily enough, he's been a lot nicer to me since.
-
This is the serious part of the site.
It was until you got here, anyway.
I'm asking for help.
Smart people are more polite to the people they want help from, if they don't want sabotaged help.
-
Smart people are more polite to the people they want help from, if they don't want sabotaged help.
Blakey is not a smart man...
-
-
I know, but he likes being spoon fed.
-
I know, but he likes being spoon fed.
I don't think he actually likes anything except puerile ranting.
-
I don't think he actually likes anything except puerile ranting.
This place is better than a "Word A Day" calendar for my vocabulary. <not all words are new, some I am just reminded of, but still helpful>
-
The problem seems to be that WebAPI doesn't ship with a multipart/form-data formatter by default. I'm stumped as to why, but switching the request to use a Content-Type WebAPI does set a formatter for (for example, application/json) causes the request to enter my controller.
That's weird since Microsoft has documentation for sending and processing multi-part form data in WebAPI 2.
-
This place is better than a "Word A Day" calendar for my vocabulary.
You're welcome.
-
This place is better than a "Word A Day" calendar for my vocabulary.
indubitably. how fortuitous we're about the premises then!
-
Theirs works because it's not using WebAPI to automatically do mapping to a data object.
That was actually a lot of the gap in my understanding. If you tell WebAPI to handle it without data mapping, it sends you the request even if it's a type it has no Formatter class for. If you ask it to auto-map to a model, it throws a 415. Go figure.
-
I don't think he actually likes anything except puerile ranting.
Mac OS Classic.
BOOOYAAAAH!
-
-
-
Is Mono for Mac Classic a thing yet?
-
Fuck off you piece of shit. This is the serious part of the site, I'm asking for help.
Why would you expect to get that via an abrasive, abusive, worthless Internet persona with a long track record of help allergy? If the actual human being behind the blakeyrat mask needs help, perhaps that actual human being should create a second account for the purpose of being taken >0.000000000000001% seriously.
-
he likes being spoon fed
He'd suckle if he could get away with it. Unfortunately the only skill he retains from that phase of his career is a solid grounding in how to suck.
-
the only skill he retains from that phase of his career is a solid grounding in how to suck.
Then you really would think he would have made it farther up the corporate ladder...
-
Frustrated by teeth
-
Frustrated by teeth
So, you are saying, it is more a matter of form than enthusiasm?
-
It's form over suction.
-
-
If the actual human being behind the blakeyrat mask needs help, perhaps that actual human being should create a second account for the purpose of being taken >0.000000000000001% seriously.
I wonder if the real human deserves the help, either, but I don't have to make that judgment call today.
-
Blakey reminds me of myself when I look for help online.
It's not something I should admit to, and it ain't pretty to look at - but it's good for one's heart, I find.Not the best for getting answers, but one could make an argument that one's health is more important...
-
I wonder if the real human deserves the help, either
If the real human behind blakey were half smart, whether or not he deserved it would not matter; he'd simply trade on the reasonable assumption of good faith that's the only thing that actually keeps people coming to these places to talk to each other. And as long as nobody doxxed him, then he'd get his help and be happy, and we'd give our help and be happy, and everybody would win.
But if somebody did out his new sock puppet, it would not be long before the consequences of his old persona's consistently hostile attitude came home to roost.
Blakey's human appears to labour under the misapprehension that sustained and consistent venom is funny. Well, maybe it could be, for a month or two. But the novelty corroded off this particular one a long, long time ago, and now it's merely one more shitty thing to make a shitty day shittier.
Even taking the occasional swipe at it is getting old.
@blakeyrat needs to retire.
-
Blakey's human appears to labour under the misapprehension that sustained and consistent venom is funny. Well, maybe it could be, for a month or two. But the novelty corroded off this particular one a long, long time ago, and now it's merely one more shitty thing to make a shitty day shittier.
Even taking the occasional swipe at it is getting old.
I only read this site and rarely post but I find him hilarious. It's like when a toddler gets super angry (often over nothing) and frowns and stamps their feet. The reaction is laughter, not dismay or offense. I don't get why so many folks treat him so seriously and get so offended by him. He's a silly bastard, that adds a lot of colour to the forum. In my opinion.Though of course, I also find it amusing how people give him shit when he actually needs help too. That's equally funny
-
It's like when a toddler gets super angry (often over nothing) and frowns and stamps their feet. The reaction is laughter, not dismay or offense.
Toddlers grow up, and that is what makes their struggles funny; we recognize our own early struggles in theirs, and happily anticipate sharing our amusement with them when they're looking after toddlers of their own. Comparing @blakeyrat's formulaic industrial outrage to a toddler's is like comparing Potted Meat Food Product to steak, Cheez Whiz to cheese, or My Little Pony to drama.
-
Hmmm I wouldn't be quite on the same page as you there.
I just enjoy seeing senseless, baseless, yet for some reason intense rage. The combination of how fierce it can be, compared to how little there is to be angry with in the first place, is what I find amusing. There's no deeper meaning for me, so maybe the toddler example was bad.
Seeing Mr Blakey scream abuse at someone for posting a freaking GIF just makes me lol. It's so over the top, exaggerated, unnecessary. Makes me happy anyway, though perhaps I'm just a freak like that :)
-
You know who else was amused by rage? The Nazis! WWII was one giant troll.
You monster
-
scream abuse at someone for posting a freaking GIF
The thing everyone did when @wood did it during the early discodays?
-
Yeah, it was super funny then too