Retrieve the File Attached to a Stock Item

If you are using the REST API to integrate MYOB Acumatica with an external system, this external system can retrieve the attachments of a stock item. For example, in an online store, you may need to display an image of each item that is sold in the store. Images for the items can be stored in MYOB Acumatica as attachments to the Stock Items (IN202500) form. To display an image of a stock item in the online store, you should retrieve the list of images that are attached to the stock item as described in Retrieve the List of Attachments of a Stock Item and then export the needed image as described in this topic.

Testing of the Request

Before you test the code below, you need to do the following to configure your client application and the MYOB Acumatica instance to be used:

  1. Deploy a new MYOB Acumatica instance with the T100 dataset. For details on deploying an instance, see To Deploy an MYOB Acumatica Instance in the Installation Guide.
  2. If you use Postman as the client application for testing, in the IntegrationDevelopmentGuide.postman_collection.json collection (which is located in the IntegrationDevelopment\Help folder of the Help-and-Training-Examples repository on GitHub), make sure the collection variables have the proper values.
  3. To sign in to the instance in the client application, use the tenant name (which you specified when you created the instance) and the MYSTORE branch.
  4. To find out the URL for the retrieval of the attachment, execute the request that is described in Retrieve the List of Attachments of a Stock Item.

Requests

Tip: In the request examples below, <MYOB Acumatica instance URL> is the URL of the MYOB Acumatica instance (such as https://my.acumatica.com/MyInstance). You can omit the instance name in the URL (such as https://my.acumatica.com) if the instance is installed in the root of the website.

To retrieve the file attached to the AAMACHINE1 stock item through the REST API, you can use the URL specified in the files/href field of the response of the request that is described in Retrieve the List of Attachments of a Stock Item. An example of a request is shown below. The response will contain the contents of the T2MCRO.jpg file.

GET /9be45eb7-f97d-400b-96a5-1c4cf82faa96 HTTP/1.1
Host: [<MYOB Acumatica instance URL>]/entity/Default/23.200.001/files
Accept: application/json
Content-Type: application/json