Attach a File to a Stock Item
In this example, you attach a file to a stock item record by using the REST API.
System Preparation
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:
- Deploy a new MYOB Acumatica instance with the T100 dataset. For details on deploying an instance, see Instance Deployment: To Deploy an Instance with Demo Data in the Installation Guide.
- If you use Postman as the client application for testing, in the IntegrationDevelopmentGuide.postman_collection.json collection, make sure that the collection’s variables have the proper values. This collection is located in the IntegrationDevelopment\Help folder of the Help-and-Training-Examples repository on GitHub.
- 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.
- Perform the following prerequisite activity: Obtain the URL for Attaching a File.
Request
You can use the following sample request to attach the T2MCRO.jpg file, which is provided in the MYOB GitHub repository, to the AALEGO500 stock item through the contract-based REST API.
Tip:
In the request example 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 (that is, you can use https://my.acumatica.com) if the instance
is installed in the root of the website.PUT /entity/Default/24.200.001/files/PX.Objects.IN.InventoryItemMaint/
Item/cae53ce0-1614-e511-9b82-c86000dddf0b/T2MCRO.jpg HTTP/1.1
Host: [<MYOB Acumatica instance URL>]
Accept: application/json
Content-Type: application/octet-stream
"<The T2MCRO.jpg file in binary format>"