2

I want to send data like packageid[]=1&packageid[]2. The same applies for the amount. The key will be the same, but the value will be different.My Packageid[] would be same and values would be different.and my question is different.

HashMap<String,String> params1 = new HashMap<String,String>();
params1.put("customerId", String.valueOf(helpervalue));
params1.put("vechileId", String.valueOf(vehicalId));
params1.put("timeslotId", String.valueOf(timeSlotId));
params1.put("registrationYear", String.valueOf(registeryear));
params1.put("franchiseId", String.valueOf(helpervalue2));
params1.put("jobDate", String.valueOf(date));
params1.put("vehicleRegistrationNumber", String.valueOf(register));
params1.put("totalAmount", String.valueOf(total)+"&"+getURlFromArray1(strint));`

private String getURlFromArray1(int arr[]) {
    String makeupSTR = "";

    for(int val : arr)
        makeupSTR += arr1Key+"="+val+"&";
    if(makeupSTR.contains("&"))
         makeupSTR = makeupSTR.substring(0, makeupSTR.lastIndexOf("&"));
    return makeupSTR;
}

I am expecting to send the following query string structure:

?access=true&action=place_order&type=Add&franchiseId=1&jobDate=2016-01-30&customerId=1&vehicleRegistrationNumber=1&vehicleMakeId=1&registrationYear=2016&totalAmount=250.36&packageIds[]=1&packageIds[]=2&packageAmounts[]=20&packageAmounts[]=30

which responds with JSON like

{
    status: false,
    displayMessage: "This Slot has just been booked. Please Select a different Time Slot."
}
7
  • this is actual data which i have to send on server .. Commented Feb 23, 2016 at 11:19
  • client.zoneonedigital.com/carwash_v2/api/ws/controller/… Commented Feb 23, 2016 at 11:20
  • It's so confusing to read code with for and if statements written that way. Ive added your linked json to the question, I can't see an array there? Commented Feb 23, 2016 at 11:38
  • very sorry for rewriting...i have to send exactly this data..&franchiseId=1&jobDate=2016-01-31&customerId=12&vehicleRegistrationNumber=‌​1&vehicleMakeId=1&registrationYear=2016&totalAmount=250.36&packageIds[]=1&package‌​Ids[]=2&packageAmounts[]=20&packageAmounts[]=30 Commented Feb 23, 2016 at 14:05
  • Please don't use the comments for code like text or additional information. If you must clarify something, find the edit link under your question to add anything to your question Commented Feb 23, 2016 at 14:12

1 Answer 1

0

You need to decide how to send this "array". You can simply send it as a ;-separated string: key=val1;val2;val3, for example. In server, you split them using ;.

Example:

String values[] = { "1", "2", "3" };
String all = "";
for (String v : values)
   all += v + ";";
all = all.substring(0, all.length() - 1);
String param = "key=" + all;

You can better send json/xml.

Sign up to request clarification or add additional context in comments.

7 Comments

packageid[]=1&packageid[]=2&packageid[]=3&&packageid[]=4
very sorry for rewriting...i have to send exactly this data..&franchiseId=1&jobDate=2016-01-31&customerId=12&vehicleRegistrationNumber=1&vehicleMakeId=1&registrationYear=2016&totalAmount=250.36&packageIds[]=1&packageIds[]=2&packageAmounts[]=20&packageAmounts[]=30
bro my values are coming ...in a string from previous activity..and now i have convert it into int array...how can i put it as ..key=val1;val2;val3
like this packageIds=1;2;20;30&registrationYear=2016& ...
i am not talking about ..how to put static values....i have a String Array which have all packageid...that is strint[i]....
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.