Skip to content

Commit

Permalink
fix(reg-notify-gitlab-plugin): specify content-type causing 415 error
Browse files Browse the repository at this point in the history
  • Loading branch information
mj-hd committed Nov 24, 2023
1 parent 852ff26 commit 213f7f1
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions packages/reg-notify-gitlab-plugin/src/gitlab-api-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ export class DefaultGitLabApiClient implements GitLabApiClient {
"Private-Token": this._token,
},
});
if (400 <= res.status) {
throw new Error(`HTTP ${res.status}: Failed to request.`);
}

return res.json() as any as Promise<MergeRequestResource[]>;
}
Expand All @@ -92,9 +95,13 @@ export class DefaultGitLabApiClient implements GitLabApiClient {
method: "PUT",
headers: {
"Private-Token": this._token,
"Content-Type": "application/json",
},
body: JSON.stringify(params),
});
if (400 <= res.status) {
throw new Error(`HTTP ${res.status}: Failed to request.`);
}

return res.json() as any as Promise<MergeRequestResource>;
}
Expand All @@ -108,6 +115,9 @@ export class DefaultGitLabApiClient implements GitLabApiClient {
},
},
);
if (400 <= res.status) {
throw new Error(`HTTP ${res.status}: Failed to request.`);
}
return res.json() as any as Promise<CommitResource[]>;
}

Expand All @@ -120,6 +130,9 @@ export class DefaultGitLabApiClient implements GitLabApiClient {
},
},
);
if (400 <= res.status) {
throw new Error(`HTTP ${res.status}: Failed to request.`);
}

return res.json() as any as Promise<NoteResouce[]>;
}
Expand All @@ -131,12 +144,16 @@ export class DefaultGitLabApiClient implements GitLabApiClient {
method: "POST",
headers: {
"Private-Token": this._token,
"Content-Type": "application/json",
},
body: JSON.stringify({
body: params.body,
}),
},
);
if (400 <= res.status) {
throw new Error(`HTTP ${res.status}: Failed to request.`);
}

return res.json() as any as Promise<NoteResouce>;
}
Expand All @@ -148,12 +165,16 @@ export class DefaultGitLabApiClient implements GitLabApiClient {
method: "PUT",
headers: {
"Private-Token": this._token,
"Content-Type": "application/json",
},
body: JSON.stringify({
body: params.body,
}),
},
);
if (400 <= res.status) {
throw new Error(`HTTP ${res.status}: Failed to request.`);
}

return res.json() as any as Promise<NoteResouce>;
}
Expand All @@ -165,12 +186,16 @@ export class DefaultGitLabApiClient implements GitLabApiClient {
method: "POST",
headers: {
"Private-Token": this._token,
"Content-Type": "application/json",
},
body: JSON.stringify({
body: params.body,
}),
},
);
if (400 <= res.status) {
throw new Error(`HTTP ${res.status}: Failed to request.`);
}

return res.json() as any as Promise<DiscussionResource>;
}
Expand Down

0 comments on commit 213f7f1

Please sign in to comment.