evolution-api icon indicating copy to clipboard operation
evolution-api copied to clipboard

O endpoint /chat/findStatusMessage/{instance} retorna erro 500

Open felipeleite11 opened this issue 9 months ago • 2 comments

Welcome!

  • [x] Yes, I have searched for similar issues on GitHub and found none.

What did you do?

Preciso obter o status de uma mensagem específica a partir do seu id. Ao buscá-la através do endpoint /chat/findStatusMessage, conforme a documentação, é retornado o erro 500.

What did you expect?

O retorno do endpoint deveria ser um objeto, de acordo com o modelo abaixo:

{ "id": "cm8q4amq400tyuu5wusc6t864", "key": { "id": "3EB0B7DBD372D2EE873C63773BB00DC9221C7A3B", "fromMe": true, "remoteJid": "[email protected]" }, "pushName": "", "messageType": "conversation", "message": { "conversation": "Minha mensagem..." }, "messageTimestamp": 1743005203, "instanceId": "8b2be0e6-3a32-4694-ad96-1495ddef8068", "source": "unknown", "contextInfo": null, "MessageUpdate": [ { "status": "DELIVERY_ACK" }, { "status": "READ" } ] }

What did you observe instead of what you expected?

É retornado erro 500:

Image

Screenshots/Videos

Erro retornado:

Image

Body enviado na requisição:

Image

Which version of the API are you using?

Versão 2.

What is your environment?

Windows

Other environment specifications

No response

If applicable, paste the log output

No response

Additional Notes

No response

felipeleite11 avatar Mar 26 '25 16:03 felipeleite11

@felipeleite11 você tem a url completa do enpoint que você está chamando? Verifique se você está usando o nome da instância no lugar de {instance}.

diogodomanski avatar Mar 27 '25 10:03 diogodomanski

Também estou com o mesmo problema, mesmo informando a url completa passando o nome da instância está retornando: { "status": 500, "error": "Internal Server Error", "response": { "message": "\nInvalid S.integrationSession.update()invocation in\n/evolution/dist/main.js:161:19140\n\n 158));let g="";d.bold&&(g+=""),d.italic&&(g+="_"),d.underline&&(g+="~");let m=${g}${u}${g.split(\"\").reverse().join(\"\")};return d.url&&(m=d.children[0]?.text?[${m}]\n 159 (${d.url}):${d.url}),m}async function l(d,u,g,m,h,y,w,S){for(let E of m){if(E.type==="text"){let b="";for(let C of E.content.richText){for(let N of C.children)b+=w(N);b+=\n 160 }if(b=b.replace(/\\/g,"").replace(/__/,"").replace(/~~/,"").replace(/\n$/,""),b=b.replace(/\n$/,""),b.includes("[list]")){let C={number:s.split("@")[0],title:"",description:"",buttonText:"",footerText:"",sections:[]},N=b.match(/\title\(?=\[description\])/),=b.match(/\description\(?=\[buttonText\])/),x=b.match(/\buttonText\(?=\[footerText\])/),L=b.match(/\footerText\(?=\[menu\])/);N&&(C.title=N[1].trim()),&&(C.description=_[1].trim()),x&&(C.buttonText=x[1].trim()),L&&(C.footerText=L[1].trim());let W=b.match(/\menu\\[\/menu\]/)?.[1];if(W){let G=W.match(/\section\(?=\[section\]|\[\/section\]|\[\/menu\])/g);G&&G.forEach(K=>{let V=K.match(/title: (.?)(?:\n|$)/)?.[1]?.trim(),$=K.match(/\row\(?=\[row\]|\[\/row\]|\[\/section\]|\[\/menu\])/g),X={title:V,rows:$?.map(Cn=>({title:Cn.match(/title: (.?)(?:\n|$)/)?.[1]?.trim(),description:Cn.match(/description: (.?)(?:\n|$)/)?.[1]?.trim(),rowId:Cn.match(/rowId: (.?)(?:\n|$)/)?.[1]?.trim()}))||[]};C.sections.push(X)})}await d.listMessage(C)}else if(b.includes("[buttons]")){let C={number:s.split("@")[0],thumbnailUrl:void 0,title:"",description:"",footer:"",buttons:[]},N=b.match(/\thumbnailUrl\(?=\[title\])/),=b.match(/\title\(?=\[description\])/),x=b.match(/\description\(?=\[footer\])/),L=b.match(/\footer\(?=\[(?:reply|pix|copy|call|url))/);&&(C.title=_[1].trim()),N&&(C.thumbnailUrl=N[1].trim()),x&&(C.description=x[1].trim()),L&&(C.footer=L[1].trim());let W={reply:/\reply\(?=\[(?:reply|pix|copy|call|url)|$)/g,pix:/\pix\(?=\[(?:reply|pix|copy|call|url)|$)/g,copy:/\copy\(?=\[(?:reply|pix|copy|call|url)|$)/g,call:/\call\(?=\[(?:reply|pix|copy|call|url)|$)/g,url:/\url\(?=\[(?:reply|pix|copy|call|url)|$)/g};for(let[G,K]of Object.entries(W)){let V;for(;(V=K.exec(b))!==null;){let $=V[1].trim(),X={type:G};switch(G){case"pix":X.currency=$.match(/currency: (.?)(?:\n|$)/)?.[1]?.trim(),X.name=$.match(/name: (.?)(?:\n|$)/)?.[1]?.trim(),X.keyType=$.match(/keyType: (.?)(?:\n|$)/)?.[1]?.trim(),X.key=$.match(/key: (.?)(?:\n|$)/)?.[1]?.trim();break;case"reply":X.displayText=$.match(/displayText: (.?)(?:\n|$)/)?.[1]?.trim(),X.id=$.match(/id: (.?)(?:\n|$)/)?.[1]?.trim();break;case"copy":X.displayText=$.match(/displayText: (.?)(?:\n|$)/)?.[1]?.trim(),X.copyCode=$.match(/copyCode: (.?)(?:\n|$)/)?.[1]?.trim();break;case"call":X.displayText=$.match(/displayText: (.?)(?:\n|$)/)?.[1]?.trim(),X.phoneNumber=$.match(/phone: (.?)(?:\n|$)/)?.[1]?.trim();break;case"url":X.displayText=$.match(/displayText: (.?)(?:\n|$)/)?.[1]?.trim(),X.url=$.match(/url: (.?)(?:\n|$)/)?.[1]?.trim();break}Object.keys(X).length>1&&C.buttons.push(X)}}await d.buttonMessage(C)}else await d.textMessage({number:s.split("@")[0],delay:g?.delayMessage||1e3,text:b},!1);H("/message/sendText")}E.type==="image"&&(await d.mediaMessage({number:s.split("@")[0],delay:g?.delayMessage||1e3,mediatype:"image",media:E.content.url},null,!1),H("/message/sendMedia")),E.type==="video"&&(await d.mediaMessage({number:s.split("@")[0],delay:g?.delayMessage||1e3,mediatype:"video",media:E.content.url},null,!1),H("/message/sendMedia")),E.type==="audio"&&(await d.audioWhatsapp({number:s.split("@")[0],delay:g?.delayMessage||1e3,encoding:!0,audio:E.content.url},!1),H("/message/sendWhatsAppAudio"));let I=a(y,E.id);I&&await new Promise(b=>setTimeout(b,I1e3))}if(console.log("input",h),h){if(h.type==="choice input"){let E="",I=h.items;for(let b of I)E+=\\u25B6\\uFE0F ${b.content}\n→ 161 ;if(E=E.replace(/\n$/,""),E.includes("[list]")){let b={number:s.split("@")[0],title:"",description:"",buttonText:"",footerText:"",sections:[]},C=E.match(/\title\(?=\[description\])/),N=E.match(/\description\(?=\[buttonText\])/),=E.match(/\buttonText\(?=\[footerText\])/),x=E.match(/\footerText\(?=\[menu\])/);C&&(b.title=C[1].trim()),N&&(b.description=N[1].trim()),&&(b.buttonText=[1].trim()),x&&(b.footerText=x[1].trim());let L=E.match(/\menu\\[\/menu\]/)?.[1];if(L){let W=L.match(/\section\(?=\[section\]|\[\/section\]|\[\/menu\])/g);W&&W.forEach(G=>{let K=G.match(/title: (.?)(?:\n|$)/)?.[1]?.trim(),V=G.match(/\row\(?=\[row\]|\[\/row\]|\[\/section\]|\[\/menu\])/g),$={title:K,rows:V?.map(X=>({title:X.match(/title: (.?)(?:\n|$)/)?.[1]?.trim(),description:X.match(/description: (.?)(?:\n|$)/)?.[1]?.trim(),rowId:X.match(/rowId: (.?)(?:\n|$)/)?.[1]?.trim()}))||[]};b.sections.push($)})}await d.listMessage(b)}else if(E.includes("[buttons]")){let b={number:s.split("@")[0],thumbnailUrl:void 0,title:"",description:"",footer:"",buttons:[]},C=E.match(/\thumbnailUrl\(?=\[title\])/),N=E.match(/\title\(?=\[description\])/),=E.match(/\description\(?=\[footer\])/),x=E.match(/\footer\(?=\[(?:reply|pix|copy|call|url))/);N&&(b.title=N[1].trim()),C&&(b.thumbnailUrl=C[1].trim()),&&(b.description=[1].trim()),x&&(b.footer=x[1].trim());let L={reply:/\reply\(?=\[(?:reply|pix|copy|call|url)|$)/g,pix:/\pix\(?=\[(?:reply|pix|copy|call|url)|$)/g,copy:/\copy\(?=\[(?:reply|pix|copy|call|url)|$)/g,call:/\call\(?=\[(?:reply|pix|copy|call|url)|$)/g,url:/\url\(?=\[(?:reply|pix|copy|call|url)|$)/g};for(let[W,G]of Object.entries(L)){let K;for(;(K=G.exec(E))!==null;){let V=K[1].trim(),$={type:W};switch(W){case"pix":$.currency=V.match(/currency: (.?)(?:\n|$)/)?.[1]?.trim(),$.name=V.match(/name: (.?)(?:\n|$)/)?.[1]?.trim(),$.keyType=V.match(/keyType: (.?)(?:\n|$)/)?.[1]?.trim(),$.key=V.match(/key: (.?)(?:\n|$)/)?.[1]?.trim();break;case"reply":$.displayText=V.match(/displayText: (.?)(?:\n|$)/)?.[1]?.trim(),$.id=V.match(/id: (.?)(?:\n|$)/)?.[1]?.trim();break;case"copy":$.displayText=V.match(/displayText: (.?)(?:\n|$)/)?.[1]?.trim(),$.copyCode=V.match(/copyCode: (.?)(?:\n|$)/)?.[1]?.trim();break;case"call":$.displayText=V.match(/displayText: (.?)(?:\n|$)/)?.[1]?.trim(),$.phoneNumber=V.match(/phone: (.?)(?:\n|$)/)?.[1]?.trim();break;case"url":$.displayText=V.match(/displayText: (.?)(?:\n|$)/)?.[1]?.trim(),$.url=V.match(/url: (.?)(?:\n|$)/)?.[1]?.trim();break}Object.keys($).length>1&&b.buttons.push($)}}await d.buttonMessage(b)}else await d.textMessage({number:s.split("@")[0],delay:g?.delayMessage||1e3,text:E},!1);H("/message/sendText")}await S.integrationSession.update({\n where: {\n instanceId: "bc797143-c3be-481f-b76f-xxx",\n remoteJid: "[email protected]",\n keyId: "xxx"\n },\n take: undefined,\n + skip: Int\n })\n\nArgument skip is missing." } }`

phpnato avatar Apr 30 '25 02:04 phpnato

Tente adicionar os campos offset e page no body do request ao invés do limit, exemplo:

{
  "where": {
    "_id": "{{ $json.key.remoteJid }}",
    "id": "{{ $json.key.id }}",
    "remoteJid": "{{ $json.key.remoteJid }}",
    "fromMe": true
  },
  "offset": 10,
  "page": 1,
}

Daquisu avatar Jun 01 '25 19:06 Daquisu

Estava com o mesmo problema, e ao trocar "limit" por "offset" com "page", resolveu. Seria interessante incluir isso na documentação oficial, pois estava seguindo a documentação da API e lá só fala para usar limit. Valeu pela dica.

Tente adicionar os campos offset e page no body do request ao invés do limit, exemplo:

{ "where": { "_id": "{{ $json.key.remoteJid }}", "id": "{{ $json.key.id }}", "remoteJid": "{{ $json.key.remoteJid }}", "fromMe": true }, "offset": 10, "page": 1, }

juniorxf avatar Jun 03 '25 20:06 juniorxf

Já abri um PR para atualizar a documentação: https://github.com/EvolutionAPI/docs-evolution/pull/16

Daquisu avatar Jun 03 '25 20:06 Daquisu