0

HTTPConnection conn method

setRequestProperty

conn.setRequestProperty("","");

I have different header for different URL. So, it's not fix in my project. I need to use a array to fill the setRequestproperty data.

Individual call for setRequestProperty it's working 1stPart .

I tried to call same into Array it's not work "part 2".

1) conn.setRequestProperty("Authorization","12345678");
  conn.setRequestProperty("ReToken", "erjeorjeorjeoureorjr");


2)  

String[] array1 = new String[]{"Authorization","12345678","RefreshToken","erjeorjeorjeoureorjr"};`

                if (array1 != null) {
                    int size = array1.length;

                    for (int i = 0; i < size; i = i + 2) {
                        conn.setRequestProperty('"' + array1[i] + '"',
                                '"' + array1[i + 1] + '"');
                         Log.d(TAG,"Value Print:: " + array1[i] + " ," + 
                                 array1[i+1] );
                    }
                }
NovusMobile
  • 1,813
  • 2
  • 21
  • 48

1 Answers1

1

You are trying to convert something that is already a string into a string. Just remove the double quotes around the array. Try this:

for (int i = 0; i < size; i = i + 2) {
    conn.setRequestProperty(array1[i] ,array1[i + 1]);
    Log.d(TAG,"Value Print:: " + array1[i] + " ," + array1[i+1] );
}
Draken
  • 3,134
  • 13
  • 34
  • 54
SwapnilJ
  • 26
  • 2