Unexpected char 0x20 at 3 in header name retrofit kotlin

Viewed 3046
@Headers("key : aW5kaWhvbWU", "Content-Type : application/json")
@GET("product_cat/5")
fun getProduct(
): Call<ResponseListProduct>

val interceptor = HttpLoggingInterceptor().setLevel(HttpLoggingInterceptor.Level.BODY)
val headerInterceptor = object: Interceptor {

    override fun intercept(chain: Interceptor.Chain): Response {

        var request = chain.request()

        request = request.newBuilder()
            .addHeader("key","aW5kaWhvbWU")
            .addHeader("Content-Type","application/json")
            .addHeader("cache-control", "no-cache")
            .addHeader("postman-token", "6b02e1a7-87dc-c814-6545-65325bcd1d3d")
            .build()

        val response = chain.proceed(request)
        return response
    }
1 Answers

0x20 is an space, I would assume 3 is the position, so try to remove those spaces between your key name and the two points (:). Something like: "key: value".

That should fix your issue.

Related