Get a properties configuration from hubspot crm

More info: https://developers.hubspot.com/docs/api/crm/properties

Script hubspot Verified

by sindre svendby964 ยท 5/11/2023

The script

Submitted by hugo989 Typescript (fetch-only)
Verified 6 days ago
1
//native
2

3
// Ctrl+. to cache dependencies on imports hover, Ctrl+S to format.
4

5
type Hubspot = {
6
  token: string;
7
};
8
export async function main(
9
  auth: Hubspot,
10
  objectType: string,
11
  propertyName: string,
12
) {
13
  const res = await fetch(
14
    `https://api.hubapi.com/crm/v3/properties/${objectType}/${propertyName}?archived=false`,
15
    {
16
      headers: {
17
        Authorization: `Bearer ${auth.token}`,
18
        Accept: "application/json",
19
      },
20
      method: "GET",
21
    },
22
  );
23
  const jsonRes = await res.json();
24
  if (jsonRes.status == "error") {
25
    console.error(jsonRes);
26
    throw new Error(jsonRes.message);
27
  }
28
  return jsonRes;
29
}
30

Other submissions
  • Submitted by sindre svendby964 Deno
    Created 398 days ago
    1
    // Ctrl+. to cache dependencies on imports hover, Ctrl+S to format.
    2
    
    
    3
    type Hubspot = {
    4
      token: string;
    5
    };
    6
    export async function main(
    7
      auth: Hubspot,
    8
      objectType: string,
    9
      propertyName: string,
    10
    ) {
    11
      const res = await fetch(
    12
        `https://api.hubapi.com/crm/v3/properties/${objectType}/${propertyName}?archived=false`,
    13
        {
    14
          headers: {
    15
            Authorization: `Bearer ${auth.token}`,
    16
            Accept: "application/json",
    17
          },
    18
          method: "GET",
    19
        },
    20
      );
    21
      const jsonRes = await res.json();
    22
      if (jsonRes.status == "error") {
    23
        console.error(jsonRes);
    24
        throw new Error(jsonRes.message);
    25
      }
    26
      return jsonRes;
    27
    }
    28