0

My original problem is that my GET request was being rejected for the parameters being too long. So I thought, oh I'll just POST the parameter that's getting too long.

Well that doesn't work because that parameter is [FromUri]. So then I thought I'll just add some verb for this specific instance, but I can't figure out how.

The question is, how would I create a verb, let's say FOO, that works the same as GET?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Andrew
  • 1,571
  • 17
  • 31
  • The Uri length restriction is not related to the verb. Can't you change the [FromUri]? – CodeCaster Feb 24 '23 at 20:46
  • @CodeCaster I don't want to change it for all queries, that's why I want a new verb specifically for this case. – Andrew Feb 24 '23 at 21:03
  • A POST/PUT/FOO request can have a query string as well, and this too is subject to server/client/proxy-imposed length restrictions (nowadays around 8K). Again: the Uri length restriction is not related to the verb. Why do you thing introducing a new verb will allow you to use longer query strings? The query string is part of the Uri. – CodeCaster Feb 26 '23 at 17:27
  • @CodeCaster I'm going to put the too-long contents inside $curlOptions[CURLOPT_POSTFIELDS]. A typical GET would ignore this, and I want it to continue to ignore it. That's why I want a new verb. – Andrew Feb 28 '23 at 17:05
  • But ... CURLOPT_POSTFIELDS are going to be sent as a form (application/x-www-form-urlencoded). So you could as well just use POST? Don't confuse your fellow programmers who are going to use or work on your application, just use POST, don't invent a custom method. – CodeCaster Feb 28 '23 at 18:46
  • @CodeCaster But the POST goes to a totally different method, which also already exists. My question is how to create a new verb. Whether it's a good idea or not is irrelevant, that's what my question is. – Andrew Feb 28 '23 at 21:36
  • Wanting to create a custom verb screams [XY problem](https://xyproblem.info/), you're trying to solve the wrong problem in the wrong way. Is it caused by a controller that maps one verb to one action method? Can't you create a new endpoint? Anyway, see my answer in https://stackoverflow.com/questions/36642805/create-a-custom-http-method/36642996#36642996 for how to do so in ASP.NET Core. – CodeCaster Feb 28 '23 at 21:56
  • @CodeCaster You're entitled to your opinion but I _strongly_ disagree. I think this is the best solution to my problem without breaking existing code. A GET isn't intended to use post parameters and a POST is for creating/updating data. My options are to break the paradigm or create a new VERB for which I define the paradigm. – Andrew Mar 01 '23 at 18:15

0 Answers0