![]() |
Discord "message": "Cannot send an empty message", "code": 50006
Hey Leute,
ich scheitre gerade an Discord. Ich habe einen Webhook erstellt. Ich schaffe es aber nicht eine einfache Message zu senden. Weder mit net noch mit Indy Json String ist valide und der Content type ist auf 'application/json' Weder mit einem Stream noch mit einer TStringlist. funktioniert es. Der Code
Delphi-Quellcode:
btn2
procedure TForm5.btn1Click(Sender: TObject);
var LsList: TStringList; LResponse:string; LSStream: TStringStream; const LContent = '{"content": "Test"}'; begin LsList := TStringList.Create; LSStream:= TStringStream.Create(LContent, TEncoding.UTF8); try LResponse:= nthtpclnt1.get(FUrl).ContentAsString(); mmo1.Lines.Add('0 ' + LResponse); LsList.DefaultEncoding.UTF8; LsList.Add(LContent); nthtpclnt1.ContentType:= 'application/json'; LResponse:= nthtpclnt1.Post(FUrl,LSStream).ContentAsString(); mmo1.Lines.Add('1 ' + LResponse); LResponse:= nthtpclnt1.Post(FUrl,LsList).ContentAsString(); mmo1.Lines.Add('2 ' + LResponse); finally LsList.Free; LSStream.Free; end; // try end;
Delphi-Quellcode:
procedure TForm5.btn2Click(Sender: TObject);
var params: TStringStream; LIndy: TIdHTTP; LResponse:string; const LContent = '{"content": "Test"}'; begin LIndy:= TIdHTTP.Create(); params := TStringStream.Create(LContent, TEncoding.UTF8); try LIndy.Request.ContentType := 'application/json'; LIndy.Request.UserAgent := 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.139 Safari/537.36'; LResponse:= LIndy.Post(FUrl, params); finally LIndy.Free; params.Free; end; mmo1.Lines.Add('3 ' + LResponse); end; Die Antworten
Delphi-Quellcode:
Wahrscheinlich ist irgendwo ein simpler Fehler den ich gerade übersehe.
0 {"type": 1, "id": "67713562xxxxx", "name": "Test", "avatar": null, "channel_id": "677135529xxxx", "guild_id": "640861371927xxxxx", "token": "JlWiT1BTTWBmMxzbjoyEdeuIBv8A8Vj3bPBJxxxxxxxx"}
1 2 {"message": "Cannot send an empty message", "code": 50006} 3 Sieht wer meinen Fehler? Dank die SM:wink: |
AW: Discord "message": "Cannot send an empty message", "code": 50006
Bei deinem btn1 zumindest sollten die ' weg, wenn ihc mich nicht irre:
LSStream:= TStringStream.Create('LContent', TEncoding.UTF8); |
AW: Discord "message": "Cannot send an empty message", "code": 50006
Ja, hatte ich gerade schon berichtigt. Dann bekomme ich ein leeres Ergebnis.
|
AW: Discord "message": "Cannot send an empty message", "code": 50006
Delphi-Quellcode:
Wo wird params denn befüllt?
LResponse:= LIndy.Post(FUrl, params);
|
AW: Discord "message": "Cannot send an empty message", "code": 50006
Zitat:
Delphi-Quellcode:
const
LContent = '{"content": "Test"}';
Delphi-Quellcode:
params := TStringStream.Create(LContent, TEncoding.UTF8);
|
AW: Discord "message": "Cannot send an empty message", "code": 50006
Aber die kompletten Daten fehlen doch oder nicht?
Ignorier das. Ich sehe jetzt erst
Delphi-Quellcode:
LContent = '{"content": "Test"}';
|
AW: Discord "message": "Cannot send an empty message", "code": 50006
:-d:-d:-d
Zitat:
|
AW: Discord "message": "Cannot send an empty message", "code": 50006
mag vielleicht etwas abwegig sein.
Aber setze den Positionszeiger von LStream mal auf die Nullte Position.
Delphi-Quellcode:
Grüße
LStream.seek(0);
Klaus |
AW: Discord "message": "Cannot send an empty message", "code": 50006
Zitat:
leider nicht ..
Delphi-Quellcode:
bekomme ich ein leeres Ergebnis als Antwort
mit Position := 0
|
AW: Discord "message": "Cannot send an empty message", "code": 50006
soory mein Fehler:
Delphi-Quellcode:
aber wenn Position schon nicht hilft...
LStream.seek(soBeginning);
Grüße Klaus |
Alle Zeitangaben in WEZ +1. Es ist jetzt 02:01 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz