After calling an API that that returns a JSON, is it possible to grab a PDF within the JSON file?

Hey all,

Essentially I am trying to retrieve a PDF document from a API POST Call. It returns a JSON that looks like:

{
    "transactionId": "xxxxxxx-6d19-4ecf-xxxx-bada9167868e",
    "output": {
        "localization": {
            "localeCode": "US",
            "languageCode": "en"
        },
        "documentType": "SIGNATURE_PROOF_OF_DELIVERY",
        "documentFormat": "PDF",
        "documents": [
            "JVQgKCoJVKDbv3YoQuZjQRRmPhZ84VHZe6GK/D+HtaajV1NdoamS0EvtsJQyVsUiggPv567zcu6egtBUpRiqSwxVIkYdQQSdd1EXCjvvouBO5cobRRMqtLVZihvCbqiAMfFLQdilOFqKUuLFugVExFEvsMkEU7hc0wtLfdwEcn/tCLsj7I54cfoBCGPCrLyAyBtW7p6CcEtNRkE44sWLBQQIcPMa1YWZsykWDgitsUX+R9DaL6UcYffEi/dfykSgIAIFEYiXYD4DIdVDEMoQiLBUkIQ9Ei9R/o8g/tHUw5rGV5/d5wZc+aZ8VwDGfwNZBTg0CmVuZHN0cmVhbQplbmRvYmoKOTcgMCBvYmogPDwvSW5mbyA5NiAwIFIvRmlsdGVyL0ZsYXRlRGVjb2RlL1R5cGUvWFJlZi9XWzEgMiAyXS9JbmRleFswIDk4XS9JRCBbPGY2MGRjMDFjNzI2OTllOTc5MGViMTNjMDNkNWYzNGE2PjwyMzM3NjMzYWQ5ZWU4Zjg3MjY1ODVlNWUyZWRhY2I2MT5dL1Jvb3QgOTUgMCBSL0xlbmd0aCAyNDMvU2l6ZSA5OD4+c3RyZWFtCnicJdE5UkJxDMfx5CGLPBFBBRUXEPcF9xUVWZSOzoIZsfA8zIBo7QFsPYSFB7DzChzhma//FJ/JJJNfExEJAk+exIMwNLX9KaKPX0Y7MGI/IiwURjSes1mkY4S+jXDK8PqGtozOg9F9NiRpRN/d7T8hiMAEpCANkzAF0xDVXtFdZCALMzALcxCDHMzDAizCEuRhVPtpl1KAZSjCCqxCHNZgHTZgE7ZgG3x9UZeyA7tQgj3YhzE4gEM4gmM4gVNI6EBcyhmcwwVcQhnG4Qqu4QYqcAtVSOpg6FJqUIcG3MG9+jzF/zDeesbrL11WXP0BQk04bwplbmRzdHJlYW0KZW5kb2JqCnN0YXJ0eHJlZgo0MDA4MAolJUVPRgo="
        ]
    }
}

Any way of receiving and downloading the actual PDF document?

in short, yes

grab the document string from JSON array
Decode the Base64 representation
Save the result to file system as e.g. abc.pdf file

Decoding e.g.

3 Likes