Attach Files with Rest API

Hi All,

In Addition to my topic with Acumatica REST API where I showed how to retrieve and save records using Acumatica Contract Base Rest API I want to share with you now how can you attach files with the same way.

To Attach file you just need to put binary data by following URL:

https://<server>/entity/<endpoint>/<version>/<entity>/<key1>/<key2>/files/<filename>

For example, to attach file to stock item you will have following URL:

http://acusea.acumatica.com/entity/Default/6.00.001/StockItem/AACOMPUT01/files/image.png
Acumatica Files Rest API

File will be attached to entity automatically.

Have a nice integration!

11 Replies to “Attach Files with Rest API”

  1. With the file upload i want to specify a comment that should appear in the column “Comment”.
    How can I achieve this?

    1. I think you cannot do this in one call. You need to upload file first, than do second call with to File Maintenance screen to put comment there.
      I think File Maintenance screen may not be mapped in the Endpoint by default.

  2. Hi Sergey,

    I have a issue in attaching a pdf file to a Purchase order Screen.
    I am getting error like this –
    “message”: “An error has occurred.”,
    “exceptionMessage”: “Operation is not valid due to the current state of the object.”,
    “exceptionType”: “System.InvalidOperationException”,

    I have used put method
    PUT: localhost/AcumaticaXMSI/entity/Default/18.200.001/PurchaseOrder/PO000942/files/refNbr3.pdf
    Is there anything Wrong with this?

    1. I can attach file succesfully in StockItem by following your procedure, but unable to attach files in Purchase Order screen
      I think its due to key field what we are using, what is the Key field in Purchase Order?

      1. The answer to my question found is –
        I have specified OrderNbr (PO000942) but not OrderType and also sequence is also matters. first OrderType and then OrderNbr.
        Like this……
        PUT: localhost/AcumaticaXMSI/entity/Default/18.200.001/PurchaseOrder/RO/PO000942/files/refNbr3.pdf

    1. Do you mean you want to get the specific version or just add a version when yoг put it there?
      I guess you can add some text with version into the name

  3. It’s very useful your post.
    I’m trying to attach files to Sales Invoice. Is it possible to attach files with REST API where de document is in Closed status?
    I’m getting this error:
    “message”: “An error has occurred.”,
    “exceptionMessage”: “Error: The Save button is disabled.”

    I did it manually in Acumatica and I can upload the file even if the document is closed. But I have no success with REST

    1. Hi Anahi,
      I saw this error before, and even have seen a bug for that. Could you please advise what version of Acumatica do you use? I think it should work correctly in 218R2. In case not, please create a support case as we need to escalate to developers.

Leave a Reply

Your email address will not be published. Required fields are marked *