Bom dia pessoal, tô tentando usar uma API aqui, mas sem sucesso. Eu envio os parametros do request (chatId e body), porém tenho um retorno de que não preenchi o body.
Método de envio usando GSON:
public void sendMessage(String telefone) {
try {
Gson g = new Gson();
Message msg = new Message();
Type userType = new TypeToken<Message>() {
}.getType();
msg.setBody("Test Message");
msg.setChatId(telefone + "@c.us");
String json = g.toJson(msg, userType);
String url = url_principal + "sendMessage?" + token;
sendPost(url, json, "POST");
} catch (Exception ex) {
ex.printStackTrace();
}
}
Saída:
Enviando 'POST' requisição para a URL: https://eu24.chat-api.com/instance57720/sendMessage?token=xxxxxxxxx
Parâmetros do POST: {"chatId":"[email removido]","body":"Test Message"}
Resposta: 200
{"sent":false,"message":"Message was not sent: empty body. Please provide message text in body parameter in JSON POST."}
Documentação:
Request body:
{
"chatId": "[email removido]",
"body": "teste"
}