FreeAgent pdf to OneDrive

I have a FreeAgent api call module that saves a FreeAgent invoice as pdf. This outputs in base64. I am then trying to upload a file into OneDrive using the previous content to create a .pdf file. The file is created as expected but it cant be opened. I suspect there is an issue with the coding/format of the pdf output from FreeAgent.
How do I know what the correct pdf format should be for creating a file in OneDrive? Do I need to do some kind of hash translation?