I am using Retrofit to send request as encrypted JWT (JWE) to an API.
My service interface is:
interface APICallService {
@Headers("Content-Type: application/jwt")
@POST("/v1/api/dp_checkkyc")
fun getKycCompliantStatus(@Header("Authorization") accessToken:String, kycStatusRequest: KycStatusRequest): Call<KycCompliantBaseResponse>
}
My KycStatusRequest class is:
data class KycStatusRequest(var encryptedJWT : String)
I am hitting the API with:
fun getEKycCompliantStatus(accessToken:String, pan:String) {
var jwe = EncryptedJWTGenerator(pan).jweString //This JWE works fine with Postman
val kycStatusRequest = KycStatusRequest(jwe)
val call = getServiceInstance().getKycCompliantStatus("Bearer ${accessToken.trim()}", kycStatusRequest)
call.enqueue(object : Callback<KycCompliantBaseResponse> {
override fun onResponse(call: Call<KycCompliantBaseResponse>, response: Response<KycCompliantBaseResponse>) {
if (response.code() == 200) {
val kycResponse = response.body()!!
if (kycResponse.Response.F_PAN_STATUS.equals("ok", true))
isKycCompliant = true
else if (kycResponse.Response.F_PAN_STATUS.equals("invalid", true))
isKycCompliant = false
}
else
Toast.makeText(context,"Check kyc API failure!", Toast.LENGTH_LONG).show()
}
override fun onFailure(call: Call<KycCompliantBaseResponse>, t: Throwable) {
Toast.makeText(context,"Check kyc API failure!", Toast.LENGTH_LONG).show()
}
})
}
On using the above code I get 'Internal Server Error'
.
But on using the same jwe I used above with postman, API works fine.
I am suspecting that I am getting this error as I am wrapping my JWE in KycStatusRequest class before sending, which I think will convert it into a JSON with key-value pair.
How do I send my JWE as a raw text without any key-value pair?