Edits history of script submission #23435 for ' Get Custom Object Schema (hubspot)'

  • bunnative
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    
    /**
     * Get Custom Object Schema
     * Retrieve one custom object schema by its fully qualified name or objectTypeId. Requires crm.schemas.custom.read.
     */
    export async function main(auth: RT.Hubspot, object_type: string) {
      const url = new URL(`https://api.hubapi.com/crm/v3/schemas/${object_type}`)
    
      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