Discussions
error 500, ERR_BAD_RESPONSE when requesting in node.js env
9 months ago by octadion
Previously I had success in the Python environment but when I changed to the node.js environment I always got error 500, even though the header and payload were more or less the same, what do you think is wrong?
here's my previous python code:
url = "<https://api.d-id.com/talks">
headers = {
"accept": "application/json",
"content-type": "application/json",
"Authorization" : "Basic " + os.getenv("API_KEY_DID")
}
print(headers)
payload = {
"script": {
"type": "audio",
"audio_url": audio_path
},
"source_url": avatar_url
}
response = requests.post(url, json=payload, headers=headers)
and here's my javascript code:
try {
const url = "<https://api.d-id.com/talks">;
const headers = {
"accept": "application/json",
"content-type": "application/json",
"Authorization": "Basic XXX"
};
const payload = {
"script": {
"type": "audio",
"audio_url": audioPath
},
"source_url": avatarUrl
};
const response = await axios.post(url, payload, { headers });
Thank you!