Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/fix-rest-client-delete-body.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@rocket.chat/api-client': patch
---

Fixes `RestClient.delete` to send `params` as a request body, matching `post`/`put`. Previously the body was silently dropped, breaking DELETE endpoints that expect a body.
17 changes: 14 additions & 3 deletions packages/api-client/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,10 +188,21 @@ export class RestClient implements RestClientInterface {

async delete<TPathPattern extends MatchPathPattern<TPath>, TPath extends PathFor<'DELETE'>>(
endpoint: TPath,
_params?: ParamsFor<'DELETE', TPathPattern>,
options: Omit<RequestInit, 'method'> = {},
params?: ParamsFor<'DELETE', TPathPattern>,
{ headers, ...options }: Omit<RequestInit, 'method'> = {},
): Promise<Serialized<OperationResult<'DELETE', TPathPattern>>> {
const response = await this.send(endpoint, 'DELETE', options ?? {});
const isFormData = checkIfIsFormData(params);
const response = await this.send(endpoint, 'DELETE', {
...(params !== undefined && { body: isFormData ? buildFormData(params) : JSON.stringify(params) }),
Comment thread
Rohit3523 marked this conversation as resolved.
Comment thread
cubic-dev-ai[bot] marked this conversation as resolved.

headers: {
Accept: 'application/json',
...(!isFormData && { 'Content-Type': 'application/json' }),
Comment thread
Rohit3523 marked this conversation as resolved.
Outdated
...headers,
},

...options,
});
return response.json();
}
Comment thread
Rohit3523 marked this conversation as resolved.

Expand Down
Loading