multipart - How to upload a file in Telegram Bott api using Http client? -
i have tried send files using multipart form data, following error:
{"description":"error: bad request: chat_id empty","error_code":400,"ok":false}
here code snippet. can me out committing error?
public httpresponse<jsonnode> senddocument(integer chat_id,file f1) throws unirestexception { return unirest.post(endpoint + token + "/senddocument") header("accept", "application/json") .field("chat_id", chat_id) .field("document", f1) .asjson(); }
well, said chat_id empty. that's obvious error! question, there 2 ways senddocument telegram.
- that file in servers, should pass file_id in "document" field
- you want upload file device , said
must posted using multipart/form-data in usual way files uploaded via browser
if doing upload section correct, make sure chat_id not empty.
Comments
Post a Comment