1

When calling a GET method through WebAPI using AJAX, I receive a 400 - Bad Request.

I know this is because my url is too long; the parameter I want to send across is similar to:

1739;1591;2021;74777;629;799;29563;731;27047;34357;1271209;3071;3901;144337;3569;132053;167743;6206491;1411;52207;66317;2453729;60673;2244901;2851631;105510347;1739;2209;81733;2021;74777;94987;3514519;799;29563;37553;1389461;34357;1271209;1614779;59746823;3901;144337;183347;6783839;167743;6206491;7883921;291705077;66317;2453729;3116899;115325263;2851631;105510347;134026657;4958986309;2257;2867;106079;2623;97051;123281;4561397;1037;38369;48739;1803343;44591;1649867;2095777;77543749;5063;187331;237961;8804557;217709;8055233;10232323;378595951;86071;31846

I have read about using POST, but because the data already exists on the server, surely GET is the only and correct option?

Am I missing something fundamental about what I am trying to do?

loufar
  • 37
  • 8

1 Answers1

1

Technically spoken, you can retrieve your data through post (or any other method) just as well.

On the one hand you are right to say that if the data already exists on the server, you should expose it using GET. But if the identifiers are too long to put in a URL, there are only two things you can do:

  • Use a different method where you CAN put your parameters in the request body (like POST), but then take a look at this answer first
  • Think about why your identifiers need to be that long
Community
  • 1
  • 1
ckonig
  • 1,234
  • 2
  • 17
  • 29