GET
1:N - Read Related Records
One-to-Many: Use $expand to retrieve child records (e.g., Account → Contacts)
webapi.safeAjax({
type: "GET",
url: "/_api/accounts(account-id)?$expand=contact_customer_accounts",
success: function(data) {
console.log("Child contacts:", data.contact_customer_accounts);
}
});
GET
N:1 - Read Parent Record
Many-to-One: Use $expand to retrieve parent record (e.g., Contact → Account)
webapi.safeAjax({
type: "GET",
url: "/_api/contacts(contact-id)?$expand=parentcustomerid_account",
success: function(data) {
console.log("Parent account:", data.parentcustomerid_account);
}
});
POST
Create with N:1 Lookup
Create child record and link to parent using lookup field binding
webapi.safeAjax({
type: "POST",
url: "/_api/contacts",
contentType: "application/json",
data: JSON.stringify({
"firstname": "John",
"lastname": "Doe",
"parentcustomerid_account@odata.bind": "/accounts(account-id)"
})
});
PATCH
Update N:1 Relationship (Method 1)
Update lookup using @odata.bind annotation in PATCH request
webapi.safeAjax({
type: "PATCH",
url: "/_api/contacts(contact-id)",
contentType: "application/json",
data: JSON.stringify({
"parentcustomerid_account@odata.bind": "/accounts(new-account-id)"
})
});
PUT
Update N:1 Relationship (Method 2)
Change reference using PUT on $ref endpoint with @odata.id
webapi.safeAjax({
type: "PUT",
url: "/_api/contacts(contact-id)/parentcustomerid_account/$ref",
contentType: "application/json",
data: JSON.stringify({
"@odata.id": "/_api/accounts(new-account-id)"
})
});
DELETE
Remove N:1 Lookup (Disassociate)
Remove single-valued navigation property reference using DELETE on $ref endpoint
webapi.safeAjax({
type: "DELETE",
url: "/_api/contacts(contact-id)/parentcustomerid_account/$ref",
success: function() {
console.log("Lookup cleared");
}
});
GET
N:N - Read Many-to-Many
Many-to-Many: Use $expand with relationship collection (e.g., Contact → Marketing Lists)
webapi.safeAjax({
type: "GET",
url: "/_api/contacts(contact-id)?$expand=listmember_association",
success: function(data) {
console.log("Marketing lists:", data.listmember_association);
}
});
POST
N:N - Associate Records
Create Many-to-Many relationship using $ref endpoint
webapi.safeAjax({
type: "POST",
url: "/_api/contacts(contact-id)/listmember_association/$ref",
contentType: "application/json",
data: JSON.stringify({
"@odata.id": "/_api/lists(list-id)"
})
});
DELETE
N:N - Disassociate Records
Remove Many-to-Many relationship using $ref with $id query parameter
webapi.safeAjax({
type: "DELETE",
url: "/_api/contacts(contact-id)/listmember_association/$ref?$id=/_api/lists(list-id)",
success: function() {
console.log("Relationship removed");
}
});
Navigation Property Names
Find relationship names in Power Pages Design Studio or using $metadata endpoint
/_api/$metadata