I need to have a JSON Formatted Base64 for this, but I am not sure how to change this string to have it as Base64 JSON Format.
public String requestBody = '{["Um05dkxFSmhjZz09"]}';
Um05dkxFSmhjZz09 this is already in Base64
I need to have a JSON Formatted Base64 for this, but I am not sure how to change this string to have it as Base64 JSON Format.
public String requestBody = '{["Um05dkxFSmhjZz09"]}';
Um05dkxFSmhjZz09 this is already in Base64
Encoding/Decoding is different from Serialization/Deserialization
Try this instead:
public String requestBody = 'Um05dkxFSmhjZz09';
b = EncodingUtil.base64Decode(requestBody);
A JSON works in a key-value pair.
When you are creating JSON here, I see the value, but not the key. Hence the solution would be to create a key-value pair instead.
Like:
public String requestBody = '{"yourkey": "Um05dkxFSmhjZz09"}' //This is a JSON String
If you intend to use an array of values, use:
public String requestBody = '{"yourkeys": ["Um05dkxFSmhjZz09"]}'
and to validate any JSON in future, you could always use JSONLint
in test cases we can actually use Base64 and do
String formatJSON = JSON.serializePretty(requestBody);
to turn it into Json