将jwe作为请求主体发送,并进行改装

mi7gmzs6  于 2021-09-29  发布在  Java
关注(0)|答案(0)|浏览(156)

我使用改型将请求作为加密jwt(jwe)发送到api。
我的服务界面是:

interface APICallService {

    @Headers("Content-Type: application/jwt")
    @POST("/v1/api/dp_checkkyc")
    fun getKycCompliantStatus(@Header("Authorization") accessToken:String,  kycStatusRequest: KycStatusRequest): Call<KycCompliantBaseResponse>

}

我的KycStatus请求类是:

data class KycStatusRequest(var encryptedJWT : String)

我正在使用以下api:

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()
                }
            })
        }

在使用上述代码时,我得到 'Internal Server Error' . 但在使用我上面与postman使用的相同jwe时,api工作得很好。
我怀疑我在发送之前在kycstatusrequest类中 Package 我的jwe时遇到了这个错误,我认为这将把它转换成一个带有键值对的json。
如何在没有任何键值对的情况下将jwe作为原始文本发送?

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题