Hi Jose,
Maybe it's a silly question, but why are you trying to get the attachment with an automation script if you need to send it to an external system?
Why not create an Object Structure with the main table Asset and the Doclinks tables, an External System, and a Publish Channel? Using OOTB MIF, you can send the attachment using the non-persistent field DOCUMENTDATA from the DOCLINKS object in your OS.
If you need to send it as JSON, you can use the JSON Mapping Application to convert it to a JSON structure that your external system will understand.
It can only be configurations, and you won't need any Automation Script. If you really need to use a script, I think you can still use the same DOCUMENTDATA field to get the base64 encoded attachment from the MBO without calling Maximo's API by using mbo.getString("DOCUMENTDATA") if your main MBO is the DOCLINKS table or getting the MBOSet from ASSET to DOCKLINKS.