I use the volley library to execute the POST method, but I get the following error: Unresolved reference: entrySet.
How can I solve this?
Here is my code:
Kotlin
@Throws(AuthFailureError::class)
override fun getBody(): ByteArray? {
val params = params
if (params != null && params.size > 0) {
return encoderParameters(params, paramsEncoding)
}
return null
}
fun encoderParameters(params: HashMap<String, String>, paramsEncoding: String): ByteArray {
val encodedParams = StringBuilder()
try {
for (entry in params.entrySet()) {
encodedParams.append(URLEncoder.encode(entry.key), paramsEncoding)
encodedParams . append ('=')
encodedParams . append (URLEncoder.encode(entry.value, paramsEncoding))
encodedParams . append ('&')
}
return encodedParams.toString().toByteArray(charset(paramsEncoding))
}catch (e: UnsupportedEncodingException){
throw RuntimeException("Encoding not supported: $paramsEncoding", e)
}
}