0

I have a UI in my webapp that allows users to build fairly complex charts where they can specify chart types, chart axes, ranges, and also specify multiple filters (which can be quite complex themselves). I've written the javascript (actually CoffeeScript) in a very OO style, so that the whole state of the chart configuration can be serialized to a very neat and tidy JSON document. When the user wants to render the graph, a request is made to the server with that JSON document in the request body, and the server then responds with another JSON document containing the actual data for the chart.

My question is, what HTTP verb should I be using for this request? I'm currently using POST as a GET request with a body feels wrong, but POST doesn't really fit. Any ideas would be helpful!

Kara
  • 6,115
  • 16
  • 50
  • 57
Goat in toilet
  • 45
  • 1
  • 1
  • 4

1 Answers1

1

What makes you feel POST does not fit?

As GET utilizes the querystring via a parameterized / key value pairing, adding the json as one qs value would not feel right to me, where as a POST feels absolutely the right choice.

jenson-button-event
  • 18,101
  • 11
  • 89
  • 155
  • JSON in qs felt absolutely wrong! POST just seems like it should persist the resource on the server but that is my misunderstanding! – Goat in toilet Feb 01 '13 at 11:47
  • in normal circumstances i would say a quesrystirng is for filtering results of a GET, but you are not using the QS so..in REST POST is generally for create and PUT for idempotent update...that's generally..but the http protocol was around before json, so we make do.. – jenson-button-event Feb 01 '13 at 12:03
  • Well I'm technically creating a resource (in this case an idempotent create) so POST feels best. Thanks! – Goat in toilet Feb 01 '13 at 12:12