MCPcopy Index your code
hub / github.com/simstudioai/sim / resolveSpaceId

Function resolveSpaceId

apps/sim/connectors/confluence/confluence.ts:602–629  ·  view source on GitHub ↗

* Resolves a Confluence space key to its numeric space ID.

(
  cloudId: string,
  accessToken: string,
  spaceKey: string
)

Source from the content-addressed store, hash-verified

600 * Resolves a Confluence space key to its numeric space ID.
601 */
602async function resolveSpaceId(
603 cloudId: string,
604 accessToken: string,
605 spaceKey: string
606): Promise<string> {
607 const url = `https://api.atlassian.com/ex/confluence/${cloudId}/wiki/api/v2/spaces?keys=${encodeURIComponent(spaceKey)}&limit=1`
608
609 const response = await fetchWithRetry(url, {
610 method: 'GET',
611 headers: {
612 Accept: 'application/json',
613 Authorization: `Bearer ${accessToken}`,
614 },
615 })
616
617 if (!response.ok) {
618 throw new Error(`Failed to resolve space key "${spaceKey}": ${response.status}`)
619 }
620
621 const data = await response.json()
622 const results = data.results || []
623
624 if (results.length === 0) {
625 throw new Error(`Space "${spaceKey}" not found`)
626 }
627
628 return String(results[0].id)
629}

Callers 1

confluence.tsFile · 0.85

Calls 1

fetchWithRetryFunction · 0.90

Tested by

no test coverage detected