here is the code of the calling method –
NameValuePair[] data = {
new NameValuePair("first_name", firstName),
new NameValuePair("last_name", lastName),
new NameValuePair("email", email),
new NameValuePair("company", organization),
new NameValuePair("phone", phone)
};
SalesForceFormSubmissionUtil.submitForm(data,CONTACT_FOR_TYPE);
In the called method –
public static void submitForm(NameValuePair[] givendata, String contactType) {
HttpClient client = new HttpClient();
PostMethod post = new PostMethod(Constants.SALESFORCE_URL);
NameValuePair[] data = {
new NameValuePair("oid", Constants.SALESFORCE_OID),
new NameValuePair(Constants.SALESFORCE_CAMPAIGN_ID, contactType)
};
post.setRequestBody(data);
i want to add both the givendata & data and send it as a post request. Can you guys suggest me how to append both.
If you just want to combine the two arrays you can create a third array (
combinedData) with a size ofgivenData.length+data.length, then you’ll have to copy the elements from your source arrays.Though, there are plenty of other methods to solve this, as an example; below is an implementation using a
ArrayListas a middle-man/helper.output