Re: adding request parameter to a POST request
Russell Gold <[email protected]>
| Newsgroups | gmane.comp.web.httpunit.devel |
|---|---|
| Message-ID | <[email protected]> |
Your addition is exactly what is required. For a POST request,
parameter can go either in the body or the URL. If you are using the
body for other purposes, the URL is the only place you can put it. If
you are not using a custom body, POST request will be created with a
mime-encoded body constructed from the parameters.
On Mar 29, 2008, at 7:36 AM, Stephane Nicoll wrote:
> Hi there,
>
> I'm using HttpUnit for a few times now and I love it, very easy to
> use. Combined with cargo and Maven, I am able to start a container and
> run integration tests in a real environment.
>
> So far so good except that I am not able to specify a request
> parameter with a POST request. I am using the latest version (1.6.2)
>
> final WebConversation wc = new WebConversation();
> // body is an inputstream to a json object
> // mimeType is "application/json; charset=UTF-8"
> final PostMethodWebRequest req =
> new
> PostMethodWebRequest(getTilapiaBaseUrl().toExternalForm() +
> actionPath,
>
> body, mimeType);
> req.setParameter("actionType", "update");
> final WebResponse response = wc.getResponse(req);
>
> When I debug my struts action class, actionType is "'null". If I
> change the creation of the request to
>
> final PostMethodWebRequest req =
> new
> PostMethodWebRequest(getTilapiaBaseUrl().toExternalForm() + actionPath
> + "?actionType=update",
>
> body, mimeType);
>
> it works. On the client side I have a pararmeter set with name
> actionType and value update.
>
> What am I missing?
>
> Best regards,
> Stéphane
>
> --
> Large Systems Suck: This rule is 100% transitive. If you build one,
> you suck" -- S.Yegge
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace