From b5a41be7db9224c85d632488835eef4612246226 Mon Sep 17 00:00:00 2001 From: Yongtae Date: Sun, 16 Jul 2023 17:59:25 +0900 Subject: [PATCH 1/2] add -H "Content-Type: application/json" in curl command --- packages/ui/src/views/chatflows/APICodeDialog.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/packages/ui/src/views/chatflows/APICodeDialog.js b/packages/ui/src/views/chatflows/APICodeDialog.js index 5e32c1d4b93..ed9d8986c71 100644 --- a/packages/ui/src/views/chatflows/APICodeDialog.js +++ b/packages/ui/src/views/chatflows/APICodeDialog.js @@ -204,7 +204,8 @@ query({"question": "Hey, how are you?"}).then((response) => { } else if (codeLang === 'cURL') { return `curl ${baseURL}/api/v1/prediction/${dialogProps.chatflowid} \\ -X POST \\ - -d '{"question": "Hey, how are you?"}'` + -d '{"question": "Hey, how are you?"}' \\ + -H "Content-Type: application/json"` } return '' } @@ -246,6 +247,7 @@ query({"question": "Hey, how are you?"}).then((response) => { return `curl ${baseURL}/api/v1/prediction/${dialogProps.chatflowid} \\ -X POST \\ -d '{"question": "Hey, how are you?"}' \\ + -H "Content-Type: application/json" \\ -H "Authorization: Bearer ${selectedApiKey?.apiKey}"` } return '' @@ -316,7 +318,8 @@ query(formData).then((response) => { ` } else if (codeLang === 'cURL') { return `curl ${baseURL}/api/v1/prediction/${dialogProps.chatflowid} \\ - -X POST \\${getConfigExamplesForCurl(configData, 'formData')}` + -X POST \\${getConfigExamplesForCurl(configData, 'formData')} \\ + -H "Content-Type: application/json"` } return '' } @@ -363,6 +366,7 @@ query(formData).then((response) => { } else if (codeLang === 'cURL') { return `curl ${baseURL}/api/v1/prediction/${dialogProps.chatflowid} \\ -X POST \\${getConfigExamplesForCurl(configData, 'formData')} \\ + -H "Content-Type: application/json" \\ -H "Authorization: Bearer ${selectedApiKey?.apiKey}"` } return '' @@ -410,7 +414,8 @@ query({ } else if (codeLang === 'cURL') { return `curl ${baseURL}/api/v1/prediction/${dialogProps.chatflowid} \\ -X POST \\ - -d '{"question": "Hey, how are you?", "overrideConfig": {${getConfigExamplesForCurl(configData, 'json')}}'` + -d '{"question": "Hey, how are you?", "overrideConfig": {${getConfigExamplesForCurl(configData, 'json')}}' \\ + -H "Content-Type: application/json"` } return '' } @@ -460,6 +465,7 @@ query({ return `curl ${baseURL}/api/v1/prediction/${dialogProps.chatflowid} \\ -X POST \\ -d '{"question": "Hey, how are you?", "overrideConfig": {${getConfigExamplesForCurl(configData, 'json')}}' \\ + -H "Content-Type: application/json" \\ -H "Authorization: Bearer ${selectedApiKey?.apiKey}"` } return '' From 6804216c6a7e2e6bd72178a88a902f353a41d2e0 Mon Sep 17 00:00:00 2001 From: Yongtae Date: Mon, 17 Jul 2023 14:11:06 +0900 Subject: [PATCH 2/2] Update cURL command with new Content-Type header --- packages/ui/src/views/chatflows/APICodeDialog.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/ui/src/views/chatflows/APICodeDialog.js b/packages/ui/src/views/chatflows/APICodeDialog.js index ed9d8986c71..c9d5565aad1 100644 --- a/packages/ui/src/views/chatflows/APICodeDialog.js +++ b/packages/ui/src/views/chatflows/APICodeDialog.js @@ -319,7 +319,7 @@ query(formData).then((response) => { } else if (codeLang === 'cURL') { return `curl ${baseURL}/api/v1/prediction/${dialogProps.chatflowid} \\ -X POST \\${getConfigExamplesForCurl(configData, 'formData')} \\ - -H "Content-Type: application/json"` + -H "Content-Type: multipart/form-data"` } return '' } @@ -366,7 +366,7 @@ query(formData).then((response) => { } else if (codeLang === 'cURL') { return `curl ${baseURL}/api/v1/prediction/${dialogProps.chatflowid} \\ -X POST \\${getConfigExamplesForCurl(configData, 'formData')} \\ - -H "Content-Type: application/json" \\ + -H "Content-Type: multipart/form-data" \\ -H "Authorization: Bearer ${selectedApiKey?.apiKey}"` } return ''