2

I'm currently creating both the client and server app using ActiveResource for web servicing. The client has a long string (:history) that needs a conversion process done by the server.

Here, the client calls the post method on my object which extends ActiveResource::Base

active_resource.post(:convert, {:history => hh, :format => format})

This line errors complaining that the URI is too long:

ActiveResource::ClientError Failed. Response code = 414. Response message = Request-URI Too Large.

What other options do I have for sending "large" data ? Probably looking in the neighborhood of 2000 characters of data for the hh string above.

Thanks!

4

2 回答 2

6

So the signature for the post method is:

post(custom_method_name, options = {}, body = '')

So, when you do:

active_resource.post(:convert, {:history => hh, :format => format})

It's putting your post variables in the options hash, which comes out in your query string for the post.

What you want to do is:

active_resource.post(:convert, nil, {:history => hh, :format => format}.to_json)
于 2012-02-08T04:00:35.737 回答
0

I didn't think post parameters factored into URI length. Are you sure it's the hh string and not the actual URI that active_resource.post is using?

于 2011-03-02T15:08:40.067 回答