//native
/**
* Find Contacts
* List the connected account's contacts, optionally narrowed by an OData `filter` (e.g. `startswith(displayName,'Al')` or `emailAddresses/any(a:a/address eq 'alice@example.com')`). Pass the returned `@odata.nextLink` as `next_link` for the next page. Requires Contacts.Read (covered by the default Contacts.ReadWrite).
*/
export async function main(
auth: RT.Outlook,
filter: string | undefined,
order_by: string | undefined,
select: string | undefined,
top: number = 25,
next_link: string | undefined
) {
if (
next_link != null &&
next_link !== "" &&
!next_link.startsWith("https://graph.microsoft.com/")
) {
throw new Error(
"next_link must be an @odata.nextLink returned by Microsoft Graph"
)
}
let url: URL
if (next_link != null && next_link !== "") {
url = new URL(next_link)
} else {
url = new URL("https://graph.microsoft.com/v1.0/me/contacts")
url.searchParams.append("$top", String(top))
if (filter != null && filter !== "") {
url.searchParams.append("$filter", filter)
}
if (order_by != null && order_by !== "") {
url.searchParams.append("$orderby", order_by)
}
if (select != null && select !== "") {
url.searchParams.append("$select", select)
}
}
const response = await fetch(url, {
headers: {
Authorization: `Bearer ${auth.token}`,
Accept: "application/json",
},
})
if (!response.ok) {
throw new Error(`${response.status} ${await response.text()}`)
}
return await response.json()
}
Submitted by hugo989 6 hours ago
//native
/**
* Find Contacts
* List the connected account's contacts, optionally narrowed by an OData `filter` (e.g. `startswith(displayName,'Al')` or `emailAddresses/any(a:a/address eq 'alice@example.com')`). Pass the returned `@odata.nextLink` as `next_link` for the next page. Requires Contacts.Read on the connection.
*/
export async function main(
auth: RT.Outlook,
filter: string | undefined,
order_by: string | undefined,
select: string | undefined,
top: number = 25,
next_link: string | undefined
) {
if (
next_link != null &&
next_link !== "" &&
!next_link.startsWith("https://graph.microsoft.com/")
) {
throw new Error(
"next_link must be an @odata.nextLink returned by Microsoft Graph"
)
}
let url: URL
if (next_link != null && next_link !== "") {
url = new URL(next_link)
} else {
url = new URL("https://graph.microsoft.com/v1.0/me/contacts")
url.searchParams.append("$top", String(top))
if (filter != null && filter !== "") {
url.searchParams.append("$filter", filter)
}
if (order_by != null && order_by !== "") {
url.searchParams.append("$orderby", order_by)
}
if (select != null && select !== "") {
url.searchParams.append("$select", select)
}
}
const response = await fetch(url, {
headers: {
Authorization: `Bearer ${auth.token}`,
Accept: "application/json",
},
})
if (!response.ok) {
throw new Error(`${response.status} ${await response.text()}`)
}
return await response.json()
}
Submitted by hugo989 6 hours ago