David Vasandani
David Vasandani

Reputation: 1940

POST base64 data in a URL

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

Upvotes: 1

Views: 3244

Answers (4)

Bart Friederichs
Bart Friederichs

Reputation: 33521

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)

Upvotes: 0

V H
V H

Reputation: 8587

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

Upvotes: 0

Fernando Carletti
Fernando Carletti

Reputation: 11

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.

Upvotes: 1

Richard Brown
Richard Brown

Reputation: 11436

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.

Upvotes: 2

Related Questions