Java Questions
Java Questions

Reputation: 7953

how to set custom param in BasicHttpParams

the following is my piese of code where i set custome parameters

CreateRequisitionRO[] request = new CreateRequisitionRO[1];
boolean validateOnly = true;
HttpPost postURI = new HttpPost("http://localhost:8080/api/trade/createrequisition");

            // Setup the request parameters
            BasicHttpParams params = new BasicHttpParams();
            params.setParameter("CreateRequisitionRO", request.toString());
            params.setParameter("validateOnly", "true");
            postURI.setParams(params);
            HttpResponse responseURL = client.execute(postURI);

in the above CreateRequisitionRO user defined class and i have Boolean type too.

i am not able to set them in to params.setParameter since it accepts only string. how to set my class as a parameter because the method i call is defined with these custom and boolean type.

Please help to resolve this.

Best Regards

Upvotes: 0

Views: 1231

Answers (1)

Subhrajyoti Majumder
Subhrajyoti Majumder

Reputation: 41200

BasicHttpParams#setBooleanParameter which exists in super class AbstractHttpParams,

params.setBooleanParameter("validateOnly", true);

and BasicHttpParams#setParameter(String name, Object value) which accept Object as a value you can also pass your custom CreateRequisitionRO array request.

params.setParameter("CreateRequisitionRO", request);

Upvotes: 2

Related Questions