1

My developer is trying to POST an image to his web service like this:

http://consec.dev.domain.com/Services/ActivityService.svc/SubmitImage?userId=8D428BF6-51F0-43F6-947D-7E19A6A7F4BD&fileName=feels-bad.png&fileContent=iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==

this is a base64 encoded image (this one happens to be a red dot but the images we will be using are much larger)

When he tries to POST it he gets a:

HTTP Error 414. The request URL is too long.

He tells me its because my IIS configuration is wrong. I'm telling him its it code. Can someone shed some light on this or point us in a direction to begin finding some answers? thank you

David Vasandani
  • 1,840
  • 8
  • 30
  • 53
  • He's sending an incredibly large amount of data via GET parameters, which is a bad idea. It may indeed be possible to fix this by changing IIS' configuration, but an even better solution would be to actually POST the data in the first place (which he isn't doing). – Pekka Mar 09 '13 at 19:18
  • That what I thought. Hes telling me hes changing it back and forth between POST to GET but I'm still seeing it just as a url. So its always coming through as a GET if the base64 data is in the URL even if he says he's POSTing it, correct? – David Vasandani Mar 09 '13 at 19:21
  • 1
    that's what the URL (and the 414 error) suggest, yeah. He needs to get that data out of the query string – Pekka Mar 09 '13 at 19:22
  • 1
    In fact, he could put it in the URL and still do a POST request. Give him the HTTP RFC and tell him to study it well. – Bart Friederichs Mar 09 '13 at 19:22

4 Answers4

2

Don't POST the data in the URL, take advantage of the post body and submit it there. It's the only way to get a lengthy amount of data submitted.

Richard Brown
  • 11,346
  • 4
  • 32
  • 43
1

The query string has a limit, see What is the maximum possible length of a query string?

You should pass the file content via post data, in the body of the request.

Community
  • 1
  • 1
0

His code is wrong. This is why HTTP supports POST requests.

Mind you, with a POST request, you can still put data in the URL. To do a proper POST, you would create a URL to define where to post, and put the data you want to POST in the request's body.

Example of GET:

GET /some/place.php?var1=value

Example of POST:

POST /some/place.php

var1=value

However, it is valid to do this:

POST /some/place.php?var1=value

var2=value2

(these examples are snipped for clarity, you will have to send some headers as well in a POST)

Bart Friederichs
  • 33,050
  • 15
  • 95
  • 195
0

Firstly its a get and not a post http request. Secondly the error is returnef by webserver. But is it bad design? Should it actually be a form button that submits fields using post raher than constructed clickable get url

V H
  • 8,382
  • 2
  • 28
  • 48
  • I thought it was a GET even though hes telling me its a POST. The error is definitely returned by the web server. We will be submitting an image using a submit button not a clickable url. – David Vasandani Mar 09 '13 at 19:25