Example of using the REST API to retrieve an association
GET associations for single entry
You can use the GET operation to get associations for a particular entry on a form. The following table lists the details of the GET operation:
URL qualifier | /entry/{formName/{entryId}/assoc/{AssociationName} formName is the name of the form for which an entry must be read. | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Method | GET | ||||||||||||||||||
Header |
| ||||||||||||||||||
Returns | Returns links for all associated entries. | ||||||||||||||||||
All possible error codes | If the request is not successful, one of the following error code is returned:
For more information, see Error-handling-for-the-REST-API. |
Example 1
The following example returns all associations on a form as links that show the related entries:
Request URL
Response Body
{
"values" : {
...
},
"_links" : {
"assoc-PurchaseOrderLineItems" : {
"href" : "/entry/PurchaseOrder/000000000000001/assoc/PurchaseOrderLineItems"
}
}
}
Example 2
The following example returns a list of entries for a specific association:
Request URL
Response Body
{
"values" : {
...
},
"_links" : {
"assoc-PurchaseOrderLineItems" : [{
"href" : "/entry/LineItem/000000000000006"
}, {
"href" : "/entry/LineItem/000000000000008"
}]
}
}
Example 3
The following example expands the entries returned for an association:
Request URL
Response Body
{
"values" : {
...
},
"_embedded" : {
"assoc-PurchaseOrderLineItems" : [{
"values" : {...},
"_links" : { "self" : { "href" : "/entry/LineItem/000000000000006" } }
}, {
"values" : {...},
"_links" : { "self" : { "href" : "/entry/LineItem/000000000000008" } }
}]
}
}
GET associations for multiple entries
You can use the GET operation to get the associations for multiple entries on a form. The following table lists the details of the GET operation:
URL qualifier | /entry/{formName}?fields=assoc(AssociationName) formName is the name of the form for which an entry must be read. | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Method | GET | ||||||||||||||||||
Header |
| ||||||||||||||||||
Parameters |
For more information, see Endpoints-in-AR-REST-API. | ||||||||||||||||||
Returns | Returns all associations for all the entries on a form. | ||||||||||||||||||
Errors | If the request is not successful, the following error code is returned: 400 - The request body is incorrect. For more information, see Error-handling-for-the-REST-API. |
Example
/entry/PurchaseOrder?q='Status'="Pending"&expand=assoc(PurchaseOrderLineItems)
Response Body
// multiple entries plus embedded related entries
{
"entries": [
{
"values" : {
"Entry ID": "00000000000001",
...
},
"_embedded" : {
"assoc-PurchaseOrderLineItems" : [{
"values" : {...},
"_links" : { "self" : { "href" : "/entry/LineItem/000000000000006" } }
}, {
"values" : {...},
"_links" : { "self" : { "href" : "/entry/LineItem/000000000000008" } }
}]
}
},
{
"values" : {
"Entry ID": "00000000000002",
...
},
"_embedded" : {
"assoc-PurchaseOrderLineItems" : [{
"values" : {...},
"_links" : { "self" : { "href" : "/entry/LineItem/000000000000013" } }
}]
}
},
...
]