# How to Search and Upload Documents with the Infor IDM REST API

> Source: https://netray.co/erp-help/infor-idm-rest-api-search-upload-document-how-to
> Publisher: Netray (netray.co), AI and integration engineering for ERP and manufacturing systems.
> Section: ERP Help

## Short answer

Infor Document Management (IDM) exposes REST services through ION API under the IDM path of your tenant. You search items with a $query expression written against an entity and its attributes, read the returned resource links to fetch the file, and create new items with a multipart request that carries an XML description of the entity and attributes plus the file stream.

## Kind

how-to

## System

infor-os

## Erp

Infor Document Management (IDM)

## Module

IDM REST API via ION API

## Query

how to search and upload documents with Infor IDM REST API

## Alternate Queries

- Infor IDM API upload document attach to ERP record
- IDM items search $query entity attribute
- Infor Document Management REST API example
- ION API IDM resources create item

## Applies To

Infor Document Management 10.x and the cloud IDM service reached through ION API; entity and attribute names are defined in your own IDM configuration

## Steps

### Search for and upload an IDM document

**Items:**

- Get an access token from ION API using a service account whose security roles include IDM access (see the .ionapi guide).
- Open IDM Administration and note the exact entity name (for example Invoice or PurchaseOrder) and the attribute names you will filter on. They are case sensitive in the query.
- Search with GET on the IDM items search resource under your tenant, passing a $query such as /Invoice[@PONumber = "4500012345"], plus $offset and $limit for paging.
- Read the response: each item lists attributes, a pid (the permanent id) and a resources block with links for the file stream. Keep the pid, not a list position.
- Download the file by following the resource link with the same bearer token and an Accept header that matches the file type.
- To upload, POST a multipart request to the items resource with an XML part that describes the entity name, the attribute values and the file name, and a second part holding the bytes.
- Check the HTTP status and the returned pid. Search for the item again to confirm the attributes were stored and the file opens.
- Set up the ERP side link, for example Drill Back or document attach, so users find the file from the transaction.

## Sections

### Writing the $query expression

**Body:**

IDM queries use an XPath-like syntax rooted at the entity. A filter on one attribute reads /Invoice[@Supplier = "ACME"], and several conditions combine with and or or. Dates are compared in the format defined for the attribute, and wildcard matching uses the asterisk. Only attributes that are marked as searchable in the entity definition can be used, so an unexpected empty result often means the attribute is not indexed.

Always page. The server caps the page size, so loop on $offset until a page returns fewer than $limit items. Sorting is supplied with a separate parameter, and the result order is not guaranteed unless you request it. Test a query first in the IDM Desktop or web search screen, because the expression mirrors what that screen builds.

**Code:**

GET https://mingle-ionapi.inforcloudsuite.com/ACME_PRD/IDM/api/items/search?$query=/Invoice[@PONumber = "4500012345"]&$offset=0&$limit=50
Authorization: Bearer <token>
Accept: application/json

### Uploading a new item

**Body:**

A create call is a multipart POST. The first part is an XML document naming the entity and listing each attribute with its value. The second part is the file. Mandatory attributes defined on the entity must be present or the request fails with a validation message, so compare your XML to the entity in IDM Administration before debugging anything else.

Large files may be rejected by a size limit in the gateway or the IDM configuration. If uploads over a few tens of megabytes fail while small ones work, check limits rather than the payload format. After creation, the item may pass through a workflow or lifecycle state, so a search immediately afterward can briefly miss it if indexing lags.

**Code:**

<?xml version="1.0" encoding="UTF-8"?>
<item xmlns="http://www.infor.com/idm">
  <entityName>Invoice</entityName>
  <attrs>
    <attr><name>PONumber</name><value>4500012345</value></attr>
    <attr><name>Supplier</name><value>ACME</value></attr>
  </attrs>
  <resrs><res><filename>inv-4500012345.pdf</filename></res></resrs>
</item>

### Linking documents back to ERP records

**Body:**

For M3, SyteLine and LN, the link from a transaction to an IDM document is built through attributes that carry the business keys, such as order number or supplier, plus the Drill Back or attachment configuration in the ERP. If you store the right keys on upload, users and APIs can find the file from the record without any extra mapping table.

Plan the attribute model before you bulk load. Changing a key later means re-indexing or re-uploading, and inconsistent values (leading zeros, different case) make exact match queries miss documents that look identical on screen.

## Pitfalls

- Using an attribute that is not searchable. The query returns nothing and no error, so check the entity definition first.
- Relying on list position in results instead of the pid, which breaks as new items arrive.
- Forgetting to page. Only the first page is returned, and a loop that stops on the first page silently drops documents.
- Mismatched case or leading zeros in key values between ERP and IDM, which defeats exact match lookups.
- Calling IDM with a token from a service account that has no IDM role, which yields 403 rather than empty results.

## Ai Angle

Document questions such as show me the signed invoice for this purchase order are really an IDM query keyed by ERP attributes. A grounded assistant can resolve the order number from the ERP, build the $query for the right entity and return the document link, while respecting IDM security. Netray custom builds can also index document text for private retrieval, with the ERP and IDM roles still applied.

## Faq

### Which URL path does the IDM REST API use?

**Answer:** In cloud tenants you call it through the ION API gateway, using the base URL from your .ionapi file, then your tenant id, then the IDM path and the items resources. Exact prefixes differ by deployment, so confirm in the ION API documentation for your release.

### Why does my IDM search return zero items?

**Answer:** Common causes are a wrong entity name, a non-searchable attribute, case or formatting differences in the value, and a service account without access to that entity. Run the same filter in the IDM search screen to see whether it returns results there.

### Can I upload a file without any attributes?

**Answer:** Not usually. The entity definition marks some attributes as mandatory and the create request fails validation if they are missing. Supply every mandatory attribute and a file name in the XML part of the multipart request.

### Is the pid the same as the item id shown in the IDM screen?

**Answer:** The pid is the permanent identifier IDM assigns to an item and is the stable reference for API calls. Display ids and version numbers can change as items are revised, so store the pid when you link to it from another system.

## Search terms

Infor IDM REST API, IDM items search query, Infor Document Management API, upload document IDM, IDM entity attributes, ION API IDM, IDM pid permanent id, Infor IDM attach document, IDM multipart upload, Infor IDM search by attribute

---
Talk to an engineer: https://netray.co/contact?intent=erp_ai | Machine catalog: https://netray.co/agent/catalog.json
