0

I'm getting an error when requesting a jsonObject.

    JsonObjectRequest jsObjRequest = new JsonObjectRequest
       (Request.Method.GET, url, null, new Response.Listener<JSONObject>() {
        ...
    }

I know the issue is in the url string because I need a calculated key to get the object. The problem is that I don't know how to do the right encode of the key to avoid the error.

Here is the way I try to encode:

public static String calculateRFC2104HMAC(String data, String key)
            throws SignatureException, NoSuchAlgorithmException, InvalidKeyException {
        SecretKeySpec signingKey = new SecretKeySpec(key.getBytes(), HMAC_SHA1_ALGORITHM);
        Mac mac = Mac.getInstance(HMAC_SHA1_ALGORITHM);
        mac.init(signingKey);
        return Base64.encode(mac.doFinal(data.getBytes()),Base64.DEFAULT).toString();
    }

1 Answers1

0

Thanks to @Anix PasBesoin, I found that the way I should enconded was:

url =  Uri.encode(url,"=");
url = url.ReplaceAll("\\%0A","");