Edits history of script submission #23454 for ' List Custom Object Schemas (hubspot)'

  • bunnative
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    
    /**
     * List Custom Object Schemas
     * List the account's custom object schemas (name, objectTypeId, properties, associations). Requires crm.schemas.custom.read.
     */
    export async function main(auth: RT.Hubspot, archived: boolean | undefined) {
      const url = new URL(`https://api.hubapi.com/crm/v3/schemas`)
      if (archived) url.searchParams.append("archived", String(archived))
    
      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 5 hours ago