0

I am having an issue when setting the Authorization header using setRequestProperty. It appears that the total length of the property value cannot exceed 80 bytes.

        if(headerData != null) {
            for (Pair pair : headerData) {
                urlConnection.setRequestProperty(pair.first.toString(),pair.second.toString());
            }
        }

The pair is:

"Authorization", "Basic TW9oYW5ATmV0UmVhY2gtTW9oYW5zLUFQR3JvdXA6TW9oYW5ATmV0UmVhY2gtTW9oYW5zLUFQR3Jv dXA=\n"

The error is: java.lang.IllegalArgumentException: Unexpected char 0x0a at 82 in header value

If I reduce the total length of the value to be under 80, it works fine.

svenyonson
  • 1,815
  • 1
  • 21
  • 30

1 Answers1

0

I found the answer here: Unexpected char 0x0a in header value when using OkHttp client in Android

I just needed to set the base64 encoding option to Base64.NO_WRAP

svenyonson
  • 1,815
  • 1
  • 21
  • 30