diff --git a/CHANGELOG.md b/CHANGELOG.md index 2cf334d..0c7db31 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,11 +1,12 @@ # Change Log -## v0.3.0 - 02 September 2020 +## v0.3.0 - 03 September 2020 A collection of accumulated fixes and minor enhancements. ### Fixed +* Pop up an error when invoking (POST) application method with an empty payload [#121](https://github.com/microsoft/vscode-dapr/issues/121) * Pop up an error "Request failed with status code 404" when publishing message [#117](https://github.com/microsoft/vscode-dapr/issues/117) * The default value of the port is "app" when invoking "Dapr: Scaffold Dapr Tasks" command [#109](https://github.com/microsoft/vscode-dapr/issues/109) * It shows "Failed to load message bundle..." after expanding "APPLICATIONS" [#104](https://github.com/microsoft/vscode-dapr/issues/104) diff --git a/src/commands/applications/invokeCommon.ts b/src/commands/applications/invokeCommon.ts index 5a62135..d0d92ff 100644 --- a/src/commands/applications/invokeCommon.ts +++ b/src/commands/applications/invokeCommon.ts @@ -76,7 +76,7 @@ export async function getPayload(context: ITelemetryContext, ui: UserInput, work value: previousPayloadString }); - const payload = (payloadString && JSON.parse(payloadString)) || undefined; + const payload = payloadString ? JSON.parse(payloadString) : undefined; await workspaceState.update(payLoadStateKey, payloadString); diff --git a/src/services/httpClient.ts b/src/services/httpClient.ts index 0429c9a..203099e 100644 --- a/src/services/httpClient.ts +++ b/src/services/httpClient.ts @@ -58,14 +58,16 @@ export default class AxiosHttpClient implements HttpClient { const config = createConfig(options?.allowRedirects, cancelTokenSource.token); - config.headers = { - 'content-type': options?.json ? 'application/json' : undefined - }; + if (data !== undefined) { + config.headers = { + 'content-type': options?.json ? 'application/json' : undefined + }; + } try { const response = await axios.post( url, - options?.json ? JSON.stringify(data) : data, + (data !== undefined && options?.json) ? JSON.stringify(data) : data, config); return { data: response.data, headers: <{[key: string]: string}>response.headers, status: response.status };