chrishubert / whatsapp-api

This project is a REST API wrapper for the whatsapp-web.js library, providing an easy-to-use interface to interact with the WhatsApp Web platform.
https://www.christophehubert.com
Other
792 stars 368 forks source link

Error sending message - Bad control character in string literal in JSON at position #162

Closed Ant0nioSouza closed 7 months ago

Ant0nioSouza commented 7 months ago

Sometimes when I try to send some message through the API http://127.0.0.1:3000/client/sendMessage/sessionID I receive this error:

SyntaxError: Bad control character in string literal in JSON at position 236
    at JSON.parse (<anonymous>)
    at parse (/home/antonio/Documents/project-x/code/whatsapp-api/node_modules/body-parser/lib/types/json.js:89:19)
    at /home/antonio/Documents/project-x/code/whatsapp-api/node_modules/body-parser/lib/read.js:128:18
    at AsyncResource.runInAsyncScope (node:async_hooks:206:9)
    at invokeCallback (/home/antonio/Documents/project-x/code/whatsapp-api/node_modules/raw-body/index.js:231:16)
    at done (/home/antonio/Documents/project-x/code/whatsapp-api/node_modules/raw-body/index.js:220:7)
    at IncomingMessage.onEnd (/home/antonio/Documents/project-x/code/whatsapp-api/node_modules/raw-body/index.js:280:7)
    at IncomingMessage.emit (node:events:518:28)
    at endReadableNT (node:internal/streams/readable:1696:12)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
SyntaxError: Bad control character in string literal in JSON at position 223
    at JSON.parse (<anonymous>)
    at parse (/home/antonio/Documents/project-x/code/whatsapp-api/node_modules/body-parser/lib/types/json.js:89:19)
    at /home/antonio/Documents/project-x/code/whatsapp-api/node_modules/body-parser/lib/read.js:128:18
    at AsyncResource.runInAsyncScope (node:async_hooks:206:9)
    at invokeCallback (/home/antonio/Documents/project-x/code/whatsapp-api/node_modules/raw-body/index.js:231:16)
    at done (/home/antonio/Documents/project-x/code/whatsapp-api/node_modules/raw-body/index.js:220:7)
    at IncomingMessage.onEnd (/home/antonio/Documents/project-x/code/whatsapp-api/node_modules/raw-body/index.js:280:7)
    at IncomingMessage.emit (node:events:518:28)
    at endReadableNT (node:internal/streams/readable:1696:12)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21)

This started recently Message Júlia - vendedora: Claro! Para adquirir o Rosa Amazônica - Serúm, acesse o site amazonicarosa.com.br e garanta o seu. Tenho certeza de que irá adorar os resultados. Qualquer dúvida, estou por aqui. 🌿

chrishubert commented 7 months ago

Can you please share the full content of the request body?