Create a user project

Creates a user project board. Returns a `410 Gone` status if the user does not have existing classic projects. If you do not have sufficient privileges to perform this action, a `401 Unauthorized` or `410 Gone` status is returned.

Script github Verified

by hugo697 ยท 10/25/2023

The script

Submitted by hugo697 Typescript (fetch-only)
Verified 366 days ago
1
type Github = {
2
  token: string;
3
};
4
/**
5
 * Create a user project
6
 * Creates a user project board. Returns a `410 Gone` status if the user does not have existing classic projects. If you do not have sufficient privileges to perform this action, a `401 Unauthorized` or `410 Gone` status is returned.
7
 */
8
export async function main(
9
  auth: Github,
10
  body: { body?: string; name: string; [k: string]: unknown }
11
) {
12
  const url = new URL(`https://api.github.com/user/projects`);
13

14
  const response = await fetch(url, {
15
    method: "POST",
16
    headers: {
17
      "Content-Type": "application/json",
18
      Authorization: "Bearer " + auth.token,
19
    },
20
    body: JSON.stringify(body),
21
  });
22
  if (!response.ok) {
23
    const text = await response.text();
24
    throw new Error(`${response.status} ${text}`);
25
  }
26
  return await response.json();
27
}
28