I'm getting an Api response as this
X-Amz-Credential=0XCA1HQW6NU67Z1FP3U1/20221011/us-east-1/s3/aws4_request
But when I send this value as query parameters in the next Api, It is automatically converted into
X-Amz-Credential=0XCA1HQW6NU67Z1FP3U1%2F20221011%2Fus-east-1%2Fs3%2Faws4_request
wherever there is / it is converted into %2F, So the Api is failing as 400 Bad request.
CodePudding user response:
I think you can fix it by first decoding the original response and then sending it as a query param to next request. You can use one of the below methods for decoding:
import android.net.Uri
Uri.decode(response)
OR
import java.net.URLDecoder
URLDecoder.decode(response, "utf-8")
For response = 0XCA1HQW6NU67Z1FP3U1/20221011/us-east-1/s3/aws4_request
,
the decoded response will be 0XCA1HQW6NU67Z1FP3U1/20221011/us-east-1/s3/aws4_request
CodePudding user response:
You can use the encoded
property of retrofit's @Query
annotation to mark the value as already encoded, preventing it from being URL
encoded again.
For example:
@Query(value = "credential", encoded = true) credential: String