Skip to content

Commit

Permalink
fix: add contentType from payload type and data as conditional to the…
Browse files Browse the repository at this point in the history
… request
  • Loading branch information
JoaoMacedo03 committed Aug 15, 2023
1 parent 24be86f commit 899c8a2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,8 @@ export type PayloadRequestZendesk = {
method: string;
pathParams?: object;
queryParams?: object;
data?: object;
contentType?: string;
data?: object | string;
options?: object;
headers?: object;
retryCount?: number;
Expand Down
7 changes: 5 additions & 2 deletions src/zendesk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,11 @@ export class ZendeskClient
url: payload.url,
method: payload.method,
secure: this.isProduction,
contentType: 'application/x-www-form-urlencoded',
httpCompleteResponse: true
contentType: payload.contentType
? payload.contentType
: 'application/x-www-form-urlencoded',
httpCompleteResponse: true,
...(payload.data && { data: payload.data })
});
} catch (error) {
if (!error.status) throw new Error(String(error));
Expand Down

0 comments on commit 899c8a2

Please sign in to comment.