From 88327168e875550b5b64334c5ceacc6a136ce264 Mon Sep 17 00:00:00 2001 From: Frederic Lavigne Date: Wed, 19 Apr 2017 08:36:01 +0200 Subject: [PATCH 1/2] =?UTF-8?q?watson=20now=20sends=20=E2=80=9Ctext/plain?= =?UTF-8?q?=E2=80=9D=20#51?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- processing/speechtotext/speechtotext.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/processing/speechtotext/speechtotext.js b/processing/speechtotext/speechtotext.js index 8f7b490f..b261bd42 100644 --- a/processing/speechtotext/speechtotext.js +++ b/processing/speechtotext/speechtotext.js @@ -66,8 +66,7 @@ function onChallengeRequest(challenge, secret, signature) { console.log('[OK] Challenge accepted!'); return { headers: { - // force Content-Type as JSON as Watson sends an Accept: application/json - 'Content-Type': 'application/json' + 'Content-Type': 'text/plain' }, // but sends the body as raw data as Watson expects plain text body: new Buffer(challenge).toString('base64') From cadb72318b23ad476537ab2e273b1214ea96cd7c Mon Sep 17 00:00:00 2001 From: Frederic Lavigne Date: Wed, 19 Apr 2017 08:56:47 +0200 Subject: [PATCH 2/2] send raw text --- processing/speechtotext/speechtotext.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/processing/speechtotext/speechtotext.js b/processing/speechtotext/speechtotext.js index b261bd42..0b110ed7 100644 --- a/processing/speechtotext/speechtotext.js +++ b/processing/speechtotext/speechtotext.js @@ -68,14 +68,16 @@ function onChallengeRequest(challenge, secret, signature) { headers: { 'Content-Type': 'text/plain' }, - // but sends the body as raw data as Watson expects plain text - body: new Buffer(challenge).toString('base64') + body: challenge }; } console.log('[KO] Signature does not match'); return { code: 500, + headers: { + 'Content-Type': 'text/plain' + }, body: 'Bad signature' }; }