Telegram Bot API
POST
A simple method for testing your bot's auth token. Requires no parameters. Returns basic information about the bot in form of a [User](https---core.telegram.org-bots-api-#user) object.
{{baseUrl}}/getMe
Examples
REQUEST
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(hnd, CURLOPT_URL, "{{baseUrl}}/getMe");
CURLcode ret = curl_easy_perform(hnd);
(require '[clj-http.client :as client])
(client/post "{{baseUrl}}/getMe")
require "http/client"
url = "{{baseUrl}}/getMe"
response = HTTP::Client.post url
puts response.body
using System.Net.Http.Headers;
var client = new HttpClient();
var request = new HttpRequestMessage
{
Method = HttpMethod.Post,
RequestUri = new Uri("{{baseUrl}}/getMe"),
};
using (var response = await client.SendAsync(request))
{
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
}
var client = new RestClient("{{baseUrl}}/getMe");
var request = new RestRequest("", Method.Post);
var response = client.Execute(request);
package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "{{baseUrl}}/getMe"
req, _ := http.NewRequest("POST", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
POST /baseUrl/getMe HTTP/1.1
Host: example.com
AsyncHttpClient client = new DefaultAsyncHttpClient();
client.prepare("POST", "{{baseUrl}}/getMe")
.execute()
.toCompletableFuture()
.thenAccept(System.out::println)
.join();
client.close();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("{{baseUrl}}/getMe"))
.method("POST", HttpRequest.BodyPublishers.noBody())
.build();
HttpResponse response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url("{{baseUrl}}/getMe")
.post(null)
.build();
Response response = client.newCall(request).execute();
HttpResponse response = Unirest.post("{{baseUrl}}/getMe")
.asString();
const data = null;
const xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener('readystatechange', function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open('POST', '{{baseUrl}}/getMe');
xhr.send(data);
import axios from 'axios';
const options = {method: 'POST', url: '{{baseUrl}}/getMe'};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const url = '{{baseUrl}}/getMe';
const options = {method: 'POST'};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
const settings = {
async: true,
crossDomain: true,
url: '{{baseUrl}}/getMe',
method: 'POST',
headers: {}
};
$.ajax(settings).done(function (response) {
console.log(response);
});
val client = OkHttpClient()
val request = Request.Builder()
.url("{{baseUrl}}/getMe")
.post(null)
.build()
val response = client.newCall(request).execute()
const http = require('https');
const options = {
method: 'POST',
hostname: 'example.com',
port: null,
path: '/baseUrl/getMe',
headers: {}
};
const req = http.request(options, function (res) {
const chunks = [];
res.on('data', function (chunk) {
chunks.push(chunk);
});
res.on('end', function () {
const body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.end();
const request = require('request');
const options = {method: 'POST', url: '{{baseUrl}}/getMe'};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
const unirest = require('unirest');
const req = unirest('POST', '{{baseUrl}}/getMe');
req.end(function (res) {
if (res.error) throw new Error(res.error);
console.log(res.body);
});
const axios = require('axios').default;
const options = {method: 'POST', url: '{{baseUrl}}/getMe'};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const fetch = require('node-fetch');
const url = '{{baseUrl}}/getMe';
const options = {method: 'POST'};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
#import
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"{{baseUrl}}/getMe"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
[request setHTTPMethod:@"POST"];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSLog(@"%@", httpResponse);
}
}];
[dataTask resume];
open Cohttp_lwt_unix
open Cohttp
open Lwt
let uri = Uri.of_string "{{baseUrl}}/getMe" in
Client.call `POST uri
>>= fun (res, body_stream) ->
(* Do stuff with the result *)
"{{baseUrl}}/getMe",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
request('POST', '{{baseUrl}}/getMe');
echo $response->getBody();
setUrl('{{baseUrl}}/getMe');
$request->setMethod(HTTP_METH_POST);
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
setRequestUrl('{{baseUrl}}/getMe');
$request->setRequestMethod('POST');
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
$response = Invoke-WebRequest -Uri '{{baseUrl}}/getMe' -Method POST
$response = Invoke-RestMethod -Uri '{{baseUrl}}/getMe' -Method POST
import http.client
conn = http.client.HTTPSConnection("example.com")
conn.request("POST", "/baseUrl/getMe")
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
import requests
url = "{{baseUrl}}/getMe"
response = requests.post(url)
print(response.json())
library(httr)
url <- "{{baseUrl}}/getMe"
response <- VERB("POST", url, content_type("application/octet-stream"))
content(response, "text")
require 'uri'
require 'net/http'
url = URI("{{baseUrl}}/getMe")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
response = http.request(request)
puts response.read_body
require 'faraday'
conn = Faraday.new(
url: 'https://example.com',
)
response = conn.post('/baseUrl/getMe') do |req|
end
puts response.status
puts response.body
use reqwest;
#[tokio::main]
pub async fn main() {
let url = "{{baseUrl}}/getMe";
let client = reqwest::Client::new();
let response = client.post(url)
.send()
.await;
let results = response.unwrap()
.json::()
.await
.unwrap();
dbg!(results);
}
curl --request POST \
--url {{baseUrl}}/getMe
http POST {{baseUrl}}/getMe
wget --quiet \
--method POST \
--output-document \
- {{baseUrl}}/getMe
import Foundation
let request = NSMutableURLRequest(url: NSURL(string: "{{baseUrl}}/getMe")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "POST"
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error as Any)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
POST
Use this method for your bot to leave a group, supergroup or channel. Returns -True- on success.
{{baseUrl}}/leaveChat
BODY json
{
"chat_id": ""
}
Examples
REQUEST
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(hnd, CURLOPT_URL, "{{baseUrl}}/leaveChat");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "content-type: application/json");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "{\n \"chat_id\": \"\"\n}");
CURLcode ret = curl_easy_perform(hnd);
(require '[clj-http.client :as client])
(client/post "{{baseUrl}}/leaveChat" {:content-type :json
:form-params {:chat_id ""}})
require "http/client"
url = "{{baseUrl}}/leaveChat"
headers = HTTP::Headers{
"content-type" => "application/json"
}
reqBody = "{\n \"chat_id\": \"\"\n}"
response = HTTP::Client.post url, headers: headers, body: reqBody
puts response.body
using System.Net.Http.Headers;
var client = new HttpClient();
var request = new HttpRequestMessage
{
Method = HttpMethod.Post,
RequestUri = new Uri("{{baseUrl}}/leaveChat"),
Content = new StringContent("{\n \"chat_id\": \"\"\n}")
{
Headers =
{
ContentType = new MediaTypeHeaderValue("application/json")
}
}
};
using (var response = await client.SendAsync(request))
{
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
}
var client = new RestClient("{{baseUrl}}/leaveChat");
var request = new RestRequest("", Method.Post);
request.AddHeader("content-type", "application/json");
request.AddParameter("application/json", "{\n \"chat_id\": \"\"\n}", ParameterType.RequestBody);
var response = client.Execute(request);
package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "{{baseUrl}}/leaveChat"
payload := strings.NewReader("{\n \"chat_id\": \"\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("content-type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
POST /baseUrl/leaveChat HTTP/1.1
Content-Type: application/json
Host: example.com
Content-Length: 19
{
"chat_id": ""
}
AsyncHttpClient client = new DefaultAsyncHttpClient();
client.prepare("POST", "{{baseUrl}}/leaveChat")
.setHeader("content-type", "application/json")
.setBody("{\n \"chat_id\": \"\"\n}")
.execute()
.toCompletableFuture()
.thenAccept(System.out::println)
.join();
client.close();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("{{baseUrl}}/leaveChat"))
.header("content-type", "application/json")
.method("POST", HttpRequest.BodyPublishers.ofString("{\n \"chat_id\": \"\"\n}"))
.build();
HttpResponse response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n \"chat_id\": \"\"\n}");
Request request = new Request.Builder()
.url("{{baseUrl}}/leaveChat")
.post(body)
.addHeader("content-type", "application/json")
.build();
Response response = client.newCall(request).execute();
HttpResponse response = Unirest.post("{{baseUrl}}/leaveChat")
.header("content-type", "application/json")
.body("{\n \"chat_id\": \"\"\n}")
.asString();
const data = JSON.stringify({
chat_id: ''
});
const xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener('readystatechange', function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open('POST', '{{baseUrl}}/leaveChat');
xhr.setRequestHeader('content-type', 'application/json');
xhr.send(data);
import axios from 'axios';
const options = {
method: 'POST',
url: '{{baseUrl}}/leaveChat',
headers: {'content-type': 'application/json'},
data: {chat_id: ''}
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const url = '{{baseUrl}}/leaveChat';
const options = {
method: 'POST',
headers: {'content-type': 'application/json'},
body: '{"chat_id":""}'
};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
const settings = {
async: true,
crossDomain: true,
url: '{{baseUrl}}/leaveChat',
method: 'POST',
headers: {
'content-type': 'application/json'
},
processData: false,
data: '{\n "chat_id": ""\n}'
};
$.ajax(settings).done(function (response) {
console.log(response);
});
val client = OkHttpClient()
val mediaType = MediaType.parse("application/json")
val body = RequestBody.create(mediaType, "{\n \"chat_id\": \"\"\n}")
val request = Request.Builder()
.url("{{baseUrl}}/leaveChat")
.post(body)
.addHeader("content-type", "application/json")
.build()
val response = client.newCall(request).execute()
const http = require('https');
const options = {
method: 'POST',
hostname: 'example.com',
port: null,
path: '/baseUrl/leaveChat',
headers: {
'content-type': 'application/json'
}
};
const req = http.request(options, function (res) {
const chunks = [];
res.on('data', function (chunk) {
chunks.push(chunk);
});
res.on('end', function () {
const body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.write(JSON.stringify({chat_id: ''}));
req.end();
const request = require('request');
const options = {
method: 'POST',
url: '{{baseUrl}}/leaveChat',
headers: {'content-type': 'application/json'},
body: {chat_id: ''},
json: true
};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
const unirest = require('unirest');
const req = unirest('POST', '{{baseUrl}}/leaveChat');
req.headers({
'content-type': 'application/json'
});
req.type('json');
req.send({
chat_id: ''
});
req.end(function (res) {
if (res.error) throw new Error(res.error);
console.log(res.body);
});
const axios = require('axios').default;
const options = {
method: 'POST',
url: '{{baseUrl}}/leaveChat',
headers: {'content-type': 'application/json'},
data: {chat_id: ''}
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const fetch = require('node-fetch');
const url = '{{baseUrl}}/leaveChat';
const options = {
method: 'POST',
headers: {'content-type': 'application/json'},
body: '{"chat_id":""}'
};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
#import
NSDictionary *headers = @{ @"content-type": @"application/json" };
NSDictionary *parameters = @{ @"chat_id": @"" };
NSData *postData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"{{baseUrl}}/leaveChat"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
[request setHTTPMethod:@"POST"];
[request setAllHTTPHeaderFields:headers];
[request setHTTPBody:postData];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSLog(@"%@", httpResponse);
}
}];
[dataTask resume];
open Cohttp_lwt_unix
open Cohttp
open Lwt
let uri = Uri.of_string "{{baseUrl}}/leaveChat" in
let headers = Header.add (Header.init ()) "content-type" "application/json" in
let body = Cohttp_lwt_body.of_string "{\n \"chat_id\": \"\"\n}" in
Client.call ~headers ~body `POST uri
>>= fun (res, body_stream) ->
(* Do stuff with the result *)
"{{baseUrl}}/leaveChat",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'chat_id' => ''
]),
CURLOPT_HTTPHEADER => [
"content-type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
request('POST', '{{baseUrl}}/leaveChat', [
'body' => '{
"chat_id": ""
}',
'headers' => [
'content-type' => 'application/json',
],
]);
echo $response->getBody();
setUrl('{{baseUrl}}/leaveChat');
$request->setMethod(HTTP_METH_POST);
$request->setHeaders([
'content-type' => 'application/json'
]);
$request->setContentType('application/json');
$request->setBody(json_encode([
'chat_id' => ''
]));
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
append(json_encode([
'chat_id' => ''
]));
$request->setRequestUrl('{{baseUrl}}/leaveChat');
$request->setRequestMethod('POST');
$request->setBody($body);
$request->setHeaders([
'content-type' => 'application/json'
]);
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
$headers=@{}
$headers.Add("content-type", "application/json")
$response = Invoke-WebRequest -Uri '{{baseUrl}}/leaveChat' -Method POST -Headers $headers -ContentType 'application/json' -Body '{
"chat_id": ""
}'
$headers=@{}
$headers.Add("content-type", "application/json")
$response = Invoke-RestMethod -Uri '{{baseUrl}}/leaveChat' -Method POST -Headers $headers -ContentType 'application/json' -Body '{
"chat_id": ""
}'
import http.client
conn = http.client.HTTPSConnection("example.com")
payload = "{\n \"chat_id\": \"\"\n}"
headers = { 'content-type': "application/json" }
conn.request("POST", "/baseUrl/leaveChat", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
import requests
url = "{{baseUrl}}/leaveChat"
payload = { "chat_id": "" }
headers = {"content-type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
library(httr)
url <- "{{baseUrl}}/leaveChat"
payload <- "{\n \"chat_id\": \"\"\n}"
encode <- "json"
response <- VERB("POST", url, body = payload, content_type("application/json"), encode = encode)
content(response, "text")
require 'uri'
require 'net/http'
url = URI("{{baseUrl}}/leaveChat")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["content-type"] = 'application/json'
request.body = "{\n \"chat_id\": \"\"\n}"
response = http.request(request)
puts response.read_body
require 'faraday'
conn = Faraday.new(
url: 'https://example.com',
headers: {'Content-Type' => 'application/json'}
)
response = conn.post('/baseUrl/leaveChat') do |req|
req.body = "{\n \"chat_id\": \"\"\n}"
end
puts response.status
puts response.body
use serde_json::json;
use reqwest;
#[tokio::main]
pub async fn main() {
let url = "{{baseUrl}}/leaveChat";
let payload = json!({"chat_id": ""});
let mut headers = reqwest::header::HeaderMap::new();
headers.insert("content-type", "application/json".parse().unwrap());
let client = reqwest::Client::new();
let response = client.post(url)
.headers(headers)
.json(&payload)
.send()
.await;
let results = response.unwrap()
.json::()
.await
.unwrap();
dbg!(results);
}
curl --request POST \
--url {{baseUrl}}/leaveChat \
--header 'content-type: application/json' \
--data '{
"chat_id": ""
}'
echo '{
"chat_id": ""
}' | \
http POST {{baseUrl}}/leaveChat \
content-type:application/json
wget --quiet \
--method POST \
--header 'content-type: application/json' \
--body-data '{\n "chat_id": ""\n}' \
--output-document \
- {{baseUrl}}/leaveChat
import Foundation
let headers = ["content-type": "application/json"]
let parameters = ["chat_id": ""] as [String : Any]
let postData = JSONSerialization.data(withJSONObject: parameters, options: [])
let request = NSMutableURLRequest(url: NSURL(string: "{{baseUrl}}/leaveChat")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error as Any)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
POST
Use this method to change the description of a group, a supergroup or a channel. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Returns -True- on success.
{{baseUrl}}/setChatDescription
BODY json
{
"chat_id": "",
"description": ""
}
Examples
REQUEST
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(hnd, CURLOPT_URL, "{{baseUrl}}/setChatDescription");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "content-type: application/json");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "{\n \"chat_id\": \"\",\n \"description\": \"\"\n}");
CURLcode ret = curl_easy_perform(hnd);
(require '[clj-http.client :as client])
(client/post "{{baseUrl}}/setChatDescription" {:content-type :json
:form-params {:chat_id ""
:description ""}})
require "http/client"
url = "{{baseUrl}}/setChatDescription"
headers = HTTP::Headers{
"content-type" => "application/json"
}
reqBody = "{\n \"chat_id\": \"\",\n \"description\": \"\"\n}"
response = HTTP::Client.post url, headers: headers, body: reqBody
puts response.body
using System.Net.Http.Headers;
var client = new HttpClient();
var request = new HttpRequestMessage
{
Method = HttpMethod.Post,
RequestUri = new Uri("{{baseUrl}}/setChatDescription"),
Content = new StringContent("{\n \"chat_id\": \"\",\n \"description\": \"\"\n}")
{
Headers =
{
ContentType = new MediaTypeHeaderValue("application/json")
}
}
};
using (var response = await client.SendAsync(request))
{
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
}
var client = new RestClient("{{baseUrl}}/setChatDescription");
var request = new RestRequest("", Method.Post);
request.AddHeader("content-type", "application/json");
request.AddParameter("application/json", "{\n \"chat_id\": \"\",\n \"description\": \"\"\n}", ParameterType.RequestBody);
var response = client.Execute(request);
package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "{{baseUrl}}/setChatDescription"
payload := strings.NewReader("{\n \"chat_id\": \"\",\n \"description\": \"\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("content-type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
POST /baseUrl/setChatDescription HTTP/1.1
Content-Type: application/json
Host: example.com
Content-Length: 40
{
"chat_id": "",
"description": ""
}
AsyncHttpClient client = new DefaultAsyncHttpClient();
client.prepare("POST", "{{baseUrl}}/setChatDescription")
.setHeader("content-type", "application/json")
.setBody("{\n \"chat_id\": \"\",\n \"description\": \"\"\n}")
.execute()
.toCompletableFuture()
.thenAccept(System.out::println)
.join();
client.close();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("{{baseUrl}}/setChatDescription"))
.header("content-type", "application/json")
.method("POST", HttpRequest.BodyPublishers.ofString("{\n \"chat_id\": \"\",\n \"description\": \"\"\n}"))
.build();
HttpResponse response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n \"chat_id\": \"\",\n \"description\": \"\"\n}");
Request request = new Request.Builder()
.url("{{baseUrl}}/setChatDescription")
.post(body)
.addHeader("content-type", "application/json")
.build();
Response response = client.newCall(request).execute();
HttpResponse response = Unirest.post("{{baseUrl}}/setChatDescription")
.header("content-type", "application/json")
.body("{\n \"chat_id\": \"\",\n \"description\": \"\"\n}")
.asString();
const data = JSON.stringify({
chat_id: '',
description: ''
});
const xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener('readystatechange', function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open('POST', '{{baseUrl}}/setChatDescription');
xhr.setRequestHeader('content-type', 'application/json');
xhr.send(data);
import axios from 'axios';
const options = {
method: 'POST',
url: '{{baseUrl}}/setChatDescription',
headers: {'content-type': 'application/json'},
data: {chat_id: '', description: ''}
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const url = '{{baseUrl}}/setChatDescription';
const options = {
method: 'POST',
headers: {'content-type': 'application/json'},
body: '{"chat_id":"","description":""}'
};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
const settings = {
async: true,
crossDomain: true,
url: '{{baseUrl}}/setChatDescription',
method: 'POST',
headers: {
'content-type': 'application/json'
},
processData: false,
data: '{\n "chat_id": "",\n "description": ""\n}'
};
$.ajax(settings).done(function (response) {
console.log(response);
});
val client = OkHttpClient()
val mediaType = MediaType.parse("application/json")
val body = RequestBody.create(mediaType, "{\n \"chat_id\": \"\",\n \"description\": \"\"\n}")
val request = Request.Builder()
.url("{{baseUrl}}/setChatDescription")
.post(body)
.addHeader("content-type", "application/json")
.build()
val response = client.newCall(request).execute()
const http = require('https');
const options = {
method: 'POST',
hostname: 'example.com',
port: null,
path: '/baseUrl/setChatDescription',
headers: {
'content-type': 'application/json'
}
};
const req = http.request(options, function (res) {
const chunks = [];
res.on('data', function (chunk) {
chunks.push(chunk);
});
res.on('end', function () {
const body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.write(JSON.stringify({chat_id: '', description: ''}));
req.end();
const request = require('request');
const options = {
method: 'POST',
url: '{{baseUrl}}/setChatDescription',
headers: {'content-type': 'application/json'},
body: {chat_id: '', description: ''},
json: true
};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
const unirest = require('unirest');
const req = unirest('POST', '{{baseUrl}}/setChatDescription');
req.headers({
'content-type': 'application/json'
});
req.type('json');
req.send({
chat_id: '',
description: ''
});
req.end(function (res) {
if (res.error) throw new Error(res.error);
console.log(res.body);
});
const axios = require('axios').default;
const options = {
method: 'POST',
url: '{{baseUrl}}/setChatDescription',
headers: {'content-type': 'application/json'},
data: {chat_id: '', description: ''}
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const fetch = require('node-fetch');
const url = '{{baseUrl}}/setChatDescription';
const options = {
method: 'POST',
headers: {'content-type': 'application/json'},
body: '{"chat_id":"","description":""}'
};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
#import
NSDictionary *headers = @{ @"content-type": @"application/json" };
NSDictionary *parameters = @{ @"chat_id": @"",
@"description": @"" };
NSData *postData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"{{baseUrl}}/setChatDescription"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
[request setHTTPMethod:@"POST"];
[request setAllHTTPHeaderFields:headers];
[request setHTTPBody:postData];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSLog(@"%@", httpResponse);
}
}];
[dataTask resume];
open Cohttp_lwt_unix
open Cohttp
open Lwt
let uri = Uri.of_string "{{baseUrl}}/setChatDescription" in
let headers = Header.add (Header.init ()) "content-type" "application/json" in
let body = Cohttp_lwt_body.of_string "{\n \"chat_id\": \"\",\n \"description\": \"\"\n}" in
Client.call ~headers ~body `POST uri
>>= fun (res, body_stream) ->
(* Do stuff with the result *)
"{{baseUrl}}/setChatDescription",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'chat_id' => '',
'description' => ''
]),
CURLOPT_HTTPHEADER => [
"content-type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
request('POST', '{{baseUrl}}/setChatDescription', [
'body' => '{
"chat_id": "",
"description": ""
}',
'headers' => [
'content-type' => 'application/json',
],
]);
echo $response->getBody();
setUrl('{{baseUrl}}/setChatDescription');
$request->setMethod(HTTP_METH_POST);
$request->setHeaders([
'content-type' => 'application/json'
]);
$request->setContentType('application/json');
$request->setBody(json_encode([
'chat_id' => '',
'description' => ''
]));
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
append(json_encode([
'chat_id' => '',
'description' => ''
]));
$request->setRequestUrl('{{baseUrl}}/setChatDescription');
$request->setRequestMethod('POST');
$request->setBody($body);
$request->setHeaders([
'content-type' => 'application/json'
]);
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
$headers=@{}
$headers.Add("content-type", "application/json")
$response = Invoke-WebRequest -Uri '{{baseUrl}}/setChatDescription' -Method POST -Headers $headers -ContentType 'application/json' -Body '{
"chat_id": "",
"description": ""
}'
$headers=@{}
$headers.Add("content-type", "application/json")
$response = Invoke-RestMethod -Uri '{{baseUrl}}/setChatDescription' -Method POST -Headers $headers -ContentType 'application/json' -Body '{
"chat_id": "",
"description": ""
}'
import http.client
conn = http.client.HTTPSConnection("example.com")
payload = "{\n \"chat_id\": \"\",\n \"description\": \"\"\n}"
headers = { 'content-type': "application/json" }
conn.request("POST", "/baseUrl/setChatDescription", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
import requests
url = "{{baseUrl}}/setChatDescription"
payload = {
"chat_id": "",
"description": ""
}
headers = {"content-type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
library(httr)
url <- "{{baseUrl}}/setChatDescription"
payload <- "{\n \"chat_id\": \"\",\n \"description\": \"\"\n}"
encode <- "json"
response <- VERB("POST", url, body = payload, content_type("application/json"), encode = encode)
content(response, "text")
require 'uri'
require 'net/http'
url = URI("{{baseUrl}}/setChatDescription")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["content-type"] = 'application/json'
request.body = "{\n \"chat_id\": \"\",\n \"description\": \"\"\n}"
response = http.request(request)
puts response.read_body
require 'faraday'
conn = Faraday.new(
url: 'https://example.com',
headers: {'Content-Type' => 'application/json'}
)
response = conn.post('/baseUrl/setChatDescription') do |req|
req.body = "{\n \"chat_id\": \"\",\n \"description\": \"\"\n}"
end
puts response.status
puts response.body
use serde_json::json;
use reqwest;
#[tokio::main]
pub async fn main() {
let url = "{{baseUrl}}/setChatDescription";
let payload = json!({
"chat_id": "",
"description": ""
});
let mut headers = reqwest::header::HeaderMap::new();
headers.insert("content-type", "application/json".parse().unwrap());
let client = reqwest::Client::new();
let response = client.post(url)
.headers(headers)
.json(&payload)
.send()
.await;
let results = response.unwrap()
.json::()
.await
.unwrap();
dbg!(results);
}
curl --request POST \
--url {{baseUrl}}/setChatDescription \
--header 'content-type: application/json' \
--data '{
"chat_id": "",
"description": ""
}'
echo '{
"chat_id": "",
"description": ""
}' | \
http POST {{baseUrl}}/setChatDescription \
content-type:application/json
wget --quiet \
--method POST \
--header 'content-type: application/json' \
--body-data '{\n "chat_id": "",\n "description": ""\n}' \
--output-document \
- {{baseUrl}}/setChatDescription
import Foundation
let headers = ["content-type": "application/json"]
let parameters = [
"chat_id": "",
"description": ""
] as [String : Any]
let postData = JSONSerialization.data(withJSONObject: parameters, options: [])
let request = NSMutableURLRequest(url: NSURL(string: "{{baseUrl}}/setChatDescription")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error as Any)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
POST
Use this method to change the list of the bot's commands. Returns -True- on success.
{{baseUrl}}/setMyCommands
BODY json
{
"commands": [
{
"command": "",
"description": ""
}
]
}
Examples
REQUEST
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(hnd, CURLOPT_URL, "{{baseUrl}}/setMyCommands");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "content-type: application/json");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "{\n \"commands\": [\n {\n \"command\": \"\",\n \"description\": \"\"\n }\n ]\n}");
CURLcode ret = curl_easy_perform(hnd);
(require '[clj-http.client :as client])
(client/post "{{baseUrl}}/setMyCommands" {:content-type :json
:form-params {:commands [{:command ""
:description ""}]}})
require "http/client"
url = "{{baseUrl}}/setMyCommands"
headers = HTTP::Headers{
"content-type" => "application/json"
}
reqBody = "{\n \"commands\": [\n {\n \"command\": \"\",\n \"description\": \"\"\n }\n ]\n}"
response = HTTP::Client.post url, headers: headers, body: reqBody
puts response.body
using System.Net.Http.Headers;
var client = new HttpClient();
var request = new HttpRequestMessage
{
Method = HttpMethod.Post,
RequestUri = new Uri("{{baseUrl}}/setMyCommands"),
Content = new StringContent("{\n \"commands\": [\n {\n \"command\": \"\",\n \"description\": \"\"\n }\n ]\n}")
{
Headers =
{
ContentType = new MediaTypeHeaderValue("application/json")
}
}
};
using (var response = await client.SendAsync(request))
{
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
}
var client = new RestClient("{{baseUrl}}/setMyCommands");
var request = new RestRequest("", Method.Post);
request.AddHeader("content-type", "application/json");
request.AddParameter("application/json", "{\n \"commands\": [\n {\n \"command\": \"\",\n \"description\": \"\"\n }\n ]\n}", ParameterType.RequestBody);
var response = client.Execute(request);
package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "{{baseUrl}}/setMyCommands"
payload := strings.NewReader("{\n \"commands\": [\n {\n \"command\": \"\",\n \"description\": \"\"\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("content-type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
POST /baseUrl/setMyCommands HTTP/1.1
Content-Type: application/json
Host: example.com
Content-Length: 80
{
"commands": [
{
"command": "",
"description": ""
}
]
}
AsyncHttpClient client = new DefaultAsyncHttpClient();
client.prepare("POST", "{{baseUrl}}/setMyCommands")
.setHeader("content-type", "application/json")
.setBody("{\n \"commands\": [\n {\n \"command\": \"\",\n \"description\": \"\"\n }\n ]\n}")
.execute()
.toCompletableFuture()
.thenAccept(System.out::println)
.join();
client.close();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("{{baseUrl}}/setMyCommands"))
.header("content-type", "application/json")
.method("POST", HttpRequest.BodyPublishers.ofString("{\n \"commands\": [\n {\n \"command\": \"\",\n \"description\": \"\"\n }\n ]\n}"))
.build();
HttpResponse response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n \"commands\": [\n {\n \"command\": \"\",\n \"description\": \"\"\n }\n ]\n}");
Request request = new Request.Builder()
.url("{{baseUrl}}/setMyCommands")
.post(body)
.addHeader("content-type", "application/json")
.build();
Response response = client.newCall(request).execute();
HttpResponse response = Unirest.post("{{baseUrl}}/setMyCommands")
.header("content-type", "application/json")
.body("{\n \"commands\": [\n {\n \"command\": \"\",\n \"description\": \"\"\n }\n ]\n}")
.asString();
const data = JSON.stringify({
commands: [
{
command: '',
description: ''
}
]
});
const xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener('readystatechange', function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open('POST', '{{baseUrl}}/setMyCommands');
xhr.setRequestHeader('content-type', 'application/json');
xhr.send(data);
import axios from 'axios';
const options = {
method: 'POST',
url: '{{baseUrl}}/setMyCommands',
headers: {'content-type': 'application/json'},
data: {commands: [{command: '', description: ''}]}
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const url = '{{baseUrl}}/setMyCommands';
const options = {
method: 'POST',
headers: {'content-type': 'application/json'},
body: '{"commands":[{"command":"","description":""}]}'
};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
const settings = {
async: true,
crossDomain: true,
url: '{{baseUrl}}/setMyCommands',
method: 'POST',
headers: {
'content-type': 'application/json'
},
processData: false,
data: '{\n "commands": [\n {\n "command": "",\n "description": ""\n }\n ]\n}'
};
$.ajax(settings).done(function (response) {
console.log(response);
});
val client = OkHttpClient()
val mediaType = MediaType.parse("application/json")
val body = RequestBody.create(mediaType, "{\n \"commands\": [\n {\n \"command\": \"\",\n \"description\": \"\"\n }\n ]\n}")
val request = Request.Builder()
.url("{{baseUrl}}/setMyCommands")
.post(body)
.addHeader("content-type", "application/json")
.build()
val response = client.newCall(request).execute()
const http = require('https');
const options = {
method: 'POST',
hostname: 'example.com',
port: null,
path: '/baseUrl/setMyCommands',
headers: {
'content-type': 'application/json'
}
};
const req = http.request(options, function (res) {
const chunks = [];
res.on('data', function (chunk) {
chunks.push(chunk);
});
res.on('end', function () {
const body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.write(JSON.stringify({commands: [{command: '', description: ''}]}));
req.end();
const request = require('request');
const options = {
method: 'POST',
url: '{{baseUrl}}/setMyCommands',
headers: {'content-type': 'application/json'},
body: {commands: [{command: '', description: ''}]},
json: true
};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
const unirest = require('unirest');
const req = unirest('POST', '{{baseUrl}}/setMyCommands');
req.headers({
'content-type': 'application/json'
});
req.type('json');
req.send({
commands: [
{
command: '',
description: ''
}
]
});
req.end(function (res) {
if (res.error) throw new Error(res.error);
console.log(res.body);
});
const axios = require('axios').default;
const options = {
method: 'POST',
url: '{{baseUrl}}/setMyCommands',
headers: {'content-type': 'application/json'},
data: {commands: [{command: '', description: ''}]}
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const fetch = require('node-fetch');
const url = '{{baseUrl}}/setMyCommands';
const options = {
method: 'POST',
headers: {'content-type': 'application/json'},
body: '{"commands":[{"command":"","description":""}]}'
};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
#import
NSDictionary *headers = @{ @"content-type": @"application/json" };
NSDictionary *parameters = @{ @"commands": @[ @{ @"command": @"", @"description": @"" } ] };
NSData *postData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"{{baseUrl}}/setMyCommands"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
[request setHTTPMethod:@"POST"];
[request setAllHTTPHeaderFields:headers];
[request setHTTPBody:postData];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSLog(@"%@", httpResponse);
}
}];
[dataTask resume];
open Cohttp_lwt_unix
open Cohttp
open Lwt
let uri = Uri.of_string "{{baseUrl}}/setMyCommands" in
let headers = Header.add (Header.init ()) "content-type" "application/json" in
let body = Cohttp_lwt_body.of_string "{\n \"commands\": [\n {\n \"command\": \"\",\n \"description\": \"\"\n }\n ]\n}" in
Client.call ~headers ~body `POST uri
>>= fun (res, body_stream) ->
(* Do stuff with the result *)
"{{baseUrl}}/setMyCommands",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'commands' => [
[
'command' => '',
'description' => ''
]
]
]),
CURLOPT_HTTPHEADER => [
"content-type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
request('POST', '{{baseUrl}}/setMyCommands', [
'body' => '{
"commands": [
{
"command": "",
"description": ""
}
]
}',
'headers' => [
'content-type' => 'application/json',
],
]);
echo $response->getBody();
setUrl('{{baseUrl}}/setMyCommands');
$request->setMethod(HTTP_METH_POST);
$request->setHeaders([
'content-type' => 'application/json'
]);
$request->setContentType('application/json');
$request->setBody(json_encode([
'commands' => [
[
'command' => '',
'description' => ''
]
]
]));
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
append(json_encode([
'commands' => [
[
'command' => '',
'description' => ''
]
]
]));
$request->setRequestUrl('{{baseUrl}}/setMyCommands');
$request->setRequestMethod('POST');
$request->setBody($body);
$request->setHeaders([
'content-type' => 'application/json'
]);
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
$headers=@{}
$headers.Add("content-type", "application/json")
$response = Invoke-WebRequest -Uri '{{baseUrl}}/setMyCommands' -Method POST -Headers $headers -ContentType 'application/json' -Body '{
"commands": [
{
"command": "",
"description": ""
}
]
}'
$headers=@{}
$headers.Add("content-type", "application/json")
$response = Invoke-RestMethod -Uri '{{baseUrl}}/setMyCommands' -Method POST -Headers $headers -ContentType 'application/json' -Body '{
"commands": [
{
"command": "",
"description": ""
}
]
}'
import http.client
conn = http.client.HTTPSConnection("example.com")
payload = "{\n \"commands\": [\n {\n \"command\": \"\",\n \"description\": \"\"\n }\n ]\n}"
headers = { 'content-type': "application/json" }
conn.request("POST", "/baseUrl/setMyCommands", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
import requests
url = "{{baseUrl}}/setMyCommands"
payload = { "commands": [
{
"command": "",
"description": ""
}
] }
headers = {"content-type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
library(httr)
url <- "{{baseUrl}}/setMyCommands"
payload <- "{\n \"commands\": [\n {\n \"command\": \"\",\n \"description\": \"\"\n }\n ]\n}"
encode <- "json"
response <- VERB("POST", url, body = payload, content_type("application/json"), encode = encode)
content(response, "text")
require 'uri'
require 'net/http'
url = URI("{{baseUrl}}/setMyCommands")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["content-type"] = 'application/json'
request.body = "{\n \"commands\": [\n {\n \"command\": \"\",\n \"description\": \"\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body
require 'faraday'
conn = Faraday.new(
url: 'https://example.com',
headers: {'Content-Type' => 'application/json'}
)
response = conn.post('/baseUrl/setMyCommands') do |req|
req.body = "{\n \"commands\": [\n {\n \"command\": \"\",\n \"description\": \"\"\n }\n ]\n}"
end
puts response.status
puts response.body
use serde_json::json;
use reqwest;
#[tokio::main]
pub async fn main() {
let url = "{{baseUrl}}/setMyCommands";
let payload = json!({"commands": (
json!({
"command": "",
"description": ""
})
)});
let mut headers = reqwest::header::HeaderMap::new();
headers.insert("content-type", "application/json".parse().unwrap());
let client = reqwest::Client::new();
let response = client.post(url)
.headers(headers)
.json(&payload)
.send()
.await;
let results = response.unwrap()
.json::()
.await
.unwrap();
dbg!(results);
}
curl --request POST \
--url {{baseUrl}}/setMyCommands \
--header 'content-type: application/json' \
--data '{
"commands": [
{
"command": "",
"description": ""
}
]
}'
echo '{
"commands": [
{
"command": "",
"description": ""
}
]
}' | \
http POST {{baseUrl}}/setMyCommands \
content-type:application/json
wget --quiet \
--method POST \
--header 'content-type: application/json' \
--body-data '{\n "commands": [\n {\n "command": "",\n "description": ""\n }\n ]\n}' \
--output-document \
- {{baseUrl}}/setMyCommands
import Foundation
let headers = ["content-type": "application/json"]
let parameters = ["commands": [
[
"command": "",
"description": ""
]
]] as [String : Any]
let postData = JSONSerialization.data(withJSONObject: parameters, options: [])
let request = NSMutableURLRequest(url: NSURL(string: "{{baseUrl}}/setMyCommands")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error as Any)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
POST
Use this method to change the title of a chat. Titles can't be changed for private chats. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Returns -True- on success.
{{baseUrl}}/setChatTitle
BODY json
{
"chat_id": "",
"title": ""
}
Examples
REQUEST
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(hnd, CURLOPT_URL, "{{baseUrl}}/setChatTitle");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "content-type: application/json");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "{\n \"chat_id\": \"\",\n \"title\": \"\"\n}");
CURLcode ret = curl_easy_perform(hnd);
(require '[clj-http.client :as client])
(client/post "{{baseUrl}}/setChatTitle" {:content-type :json
:form-params {:chat_id ""
:title ""}})
require "http/client"
url = "{{baseUrl}}/setChatTitle"
headers = HTTP::Headers{
"content-type" => "application/json"
}
reqBody = "{\n \"chat_id\": \"\",\n \"title\": \"\"\n}"
response = HTTP::Client.post url, headers: headers, body: reqBody
puts response.body
using System.Net.Http.Headers;
var client = new HttpClient();
var request = new HttpRequestMessage
{
Method = HttpMethod.Post,
RequestUri = new Uri("{{baseUrl}}/setChatTitle"),
Content = new StringContent("{\n \"chat_id\": \"\",\n \"title\": \"\"\n}")
{
Headers =
{
ContentType = new MediaTypeHeaderValue("application/json")
}
}
};
using (var response = await client.SendAsync(request))
{
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
}
var client = new RestClient("{{baseUrl}}/setChatTitle");
var request = new RestRequest("", Method.Post);
request.AddHeader("content-type", "application/json");
request.AddParameter("application/json", "{\n \"chat_id\": \"\",\n \"title\": \"\"\n}", ParameterType.RequestBody);
var response = client.Execute(request);
package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "{{baseUrl}}/setChatTitle"
payload := strings.NewReader("{\n \"chat_id\": \"\",\n \"title\": \"\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("content-type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
POST /baseUrl/setChatTitle HTTP/1.1
Content-Type: application/json
Host: example.com
Content-Length: 34
{
"chat_id": "",
"title": ""
}
AsyncHttpClient client = new DefaultAsyncHttpClient();
client.prepare("POST", "{{baseUrl}}/setChatTitle")
.setHeader("content-type", "application/json")
.setBody("{\n \"chat_id\": \"\",\n \"title\": \"\"\n}")
.execute()
.toCompletableFuture()
.thenAccept(System.out::println)
.join();
client.close();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("{{baseUrl}}/setChatTitle"))
.header("content-type", "application/json")
.method("POST", HttpRequest.BodyPublishers.ofString("{\n \"chat_id\": \"\",\n \"title\": \"\"\n}"))
.build();
HttpResponse response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n \"chat_id\": \"\",\n \"title\": \"\"\n}");
Request request = new Request.Builder()
.url("{{baseUrl}}/setChatTitle")
.post(body)
.addHeader("content-type", "application/json")
.build();
Response response = client.newCall(request).execute();
HttpResponse response = Unirest.post("{{baseUrl}}/setChatTitle")
.header("content-type", "application/json")
.body("{\n \"chat_id\": \"\",\n \"title\": \"\"\n}")
.asString();
const data = JSON.stringify({
chat_id: '',
title: ''
});
const xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener('readystatechange', function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open('POST', '{{baseUrl}}/setChatTitle');
xhr.setRequestHeader('content-type', 'application/json');
xhr.send(data);
import axios from 'axios';
const options = {
method: 'POST',
url: '{{baseUrl}}/setChatTitle',
headers: {'content-type': 'application/json'},
data: {chat_id: '', title: ''}
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const url = '{{baseUrl}}/setChatTitle';
const options = {
method: 'POST',
headers: {'content-type': 'application/json'},
body: '{"chat_id":"","title":""}'
};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
const settings = {
async: true,
crossDomain: true,
url: '{{baseUrl}}/setChatTitle',
method: 'POST',
headers: {
'content-type': 'application/json'
},
processData: false,
data: '{\n "chat_id": "",\n "title": ""\n}'
};
$.ajax(settings).done(function (response) {
console.log(response);
});
val client = OkHttpClient()
val mediaType = MediaType.parse("application/json")
val body = RequestBody.create(mediaType, "{\n \"chat_id\": \"\",\n \"title\": \"\"\n}")
val request = Request.Builder()
.url("{{baseUrl}}/setChatTitle")
.post(body)
.addHeader("content-type", "application/json")
.build()
val response = client.newCall(request).execute()
const http = require('https');
const options = {
method: 'POST',
hostname: 'example.com',
port: null,
path: '/baseUrl/setChatTitle',
headers: {
'content-type': 'application/json'
}
};
const req = http.request(options, function (res) {
const chunks = [];
res.on('data', function (chunk) {
chunks.push(chunk);
});
res.on('end', function () {
const body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.write(JSON.stringify({chat_id: '', title: ''}));
req.end();
const request = require('request');
const options = {
method: 'POST',
url: '{{baseUrl}}/setChatTitle',
headers: {'content-type': 'application/json'},
body: {chat_id: '', title: ''},
json: true
};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
const unirest = require('unirest');
const req = unirest('POST', '{{baseUrl}}/setChatTitle');
req.headers({
'content-type': 'application/json'
});
req.type('json');
req.send({
chat_id: '',
title: ''
});
req.end(function (res) {
if (res.error) throw new Error(res.error);
console.log(res.body);
});
const axios = require('axios').default;
const options = {
method: 'POST',
url: '{{baseUrl}}/setChatTitle',
headers: {'content-type': 'application/json'},
data: {chat_id: '', title: ''}
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const fetch = require('node-fetch');
const url = '{{baseUrl}}/setChatTitle';
const options = {
method: 'POST',
headers: {'content-type': 'application/json'},
body: '{"chat_id":"","title":""}'
};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
#import
NSDictionary *headers = @{ @"content-type": @"application/json" };
NSDictionary *parameters = @{ @"chat_id": @"",
@"title": @"" };
NSData *postData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"{{baseUrl}}/setChatTitle"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
[request setHTTPMethod:@"POST"];
[request setAllHTTPHeaderFields:headers];
[request setHTTPBody:postData];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSLog(@"%@", httpResponse);
}
}];
[dataTask resume];
open Cohttp_lwt_unix
open Cohttp
open Lwt
let uri = Uri.of_string "{{baseUrl}}/setChatTitle" in
let headers = Header.add (Header.init ()) "content-type" "application/json" in
let body = Cohttp_lwt_body.of_string "{\n \"chat_id\": \"\",\n \"title\": \"\"\n}" in
Client.call ~headers ~body `POST uri
>>= fun (res, body_stream) ->
(* Do stuff with the result *)
"{{baseUrl}}/setChatTitle",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'chat_id' => '',
'title' => ''
]),
CURLOPT_HTTPHEADER => [
"content-type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
request('POST', '{{baseUrl}}/setChatTitle', [
'body' => '{
"chat_id": "",
"title": ""
}',
'headers' => [
'content-type' => 'application/json',
],
]);
echo $response->getBody();
setUrl('{{baseUrl}}/setChatTitle');
$request->setMethod(HTTP_METH_POST);
$request->setHeaders([
'content-type' => 'application/json'
]);
$request->setContentType('application/json');
$request->setBody(json_encode([
'chat_id' => '',
'title' => ''
]));
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
append(json_encode([
'chat_id' => '',
'title' => ''
]));
$request->setRequestUrl('{{baseUrl}}/setChatTitle');
$request->setRequestMethod('POST');
$request->setBody($body);
$request->setHeaders([
'content-type' => 'application/json'
]);
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
$headers=@{}
$headers.Add("content-type", "application/json")
$response = Invoke-WebRequest -Uri '{{baseUrl}}/setChatTitle' -Method POST -Headers $headers -ContentType 'application/json' -Body '{
"chat_id": "",
"title": ""
}'
$headers=@{}
$headers.Add("content-type", "application/json")
$response = Invoke-RestMethod -Uri '{{baseUrl}}/setChatTitle' -Method POST -Headers $headers -ContentType 'application/json' -Body '{
"chat_id": "",
"title": ""
}'
import http.client
conn = http.client.HTTPSConnection("example.com")
payload = "{\n \"chat_id\": \"\",\n \"title\": \"\"\n}"
headers = { 'content-type': "application/json" }
conn.request("POST", "/baseUrl/setChatTitle", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
import requests
url = "{{baseUrl}}/setChatTitle"
payload = {
"chat_id": "",
"title": ""
}
headers = {"content-type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
library(httr)
url <- "{{baseUrl}}/setChatTitle"
payload <- "{\n \"chat_id\": \"\",\n \"title\": \"\"\n}"
encode <- "json"
response <- VERB("POST", url, body = payload, content_type("application/json"), encode = encode)
content(response, "text")
require 'uri'
require 'net/http'
url = URI("{{baseUrl}}/setChatTitle")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["content-type"] = 'application/json'
request.body = "{\n \"chat_id\": \"\",\n \"title\": \"\"\n}"
response = http.request(request)
puts response.read_body
require 'faraday'
conn = Faraday.new(
url: 'https://example.com',
headers: {'Content-Type' => 'application/json'}
)
response = conn.post('/baseUrl/setChatTitle') do |req|
req.body = "{\n \"chat_id\": \"\",\n \"title\": \"\"\n}"
end
puts response.status
puts response.body
use serde_json::json;
use reqwest;
#[tokio::main]
pub async fn main() {
let url = "{{baseUrl}}/setChatTitle";
let payload = json!({
"chat_id": "",
"title": ""
});
let mut headers = reqwest::header::HeaderMap::new();
headers.insert("content-type", "application/json".parse().unwrap());
let client = reqwest::Client::new();
let response = client.post(url)
.headers(headers)
.json(&payload)
.send()
.await;
let results = response.unwrap()
.json::()
.await
.unwrap();
dbg!(results);
}
curl --request POST \
--url {{baseUrl}}/setChatTitle \
--header 'content-type: application/json' \
--data '{
"chat_id": "",
"title": ""
}'
echo '{
"chat_id": "",
"title": ""
}' | \
http POST {{baseUrl}}/setChatTitle \
content-type:application/json
wget --quiet \
--method POST \
--header 'content-type: application/json' \
--body-data '{\n "chat_id": "",\n "title": ""\n}' \
--output-document \
- {{baseUrl}}/setChatTitle
import Foundation
let headers = ["content-type": "application/json"]
let parameters = [
"chat_id": "",
"title": ""
] as [String : Any]
let postData = JSONSerialization.data(withJSONObject: parameters, options: [])
let request = NSMutableURLRequest(url: NSURL(string: "{{baseUrl}}/setChatTitle")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error as Any)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
POST
Use this method to create a new sticker set owned by a user. The bot will be able to edit the sticker set thus created. You --must-- use exactly one of the fields -png-_sticker- or -tgs-_sticker-. Returns -True- on success.
{{baseUrl}}/createNewStickerSet
BODY multipartForm
Examples
REQUEST
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(hnd, CURLOPT_URL, "{{baseUrl}}/createNewStickerSet");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "content-type: multipart/form-data; boundary=---011000010111000001101001");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"contains_masks\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"emojis\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"mask_position\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"name\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"png_sticker\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"tgs_sticker\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"title\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"user_id\"\r\n\r\n\r\n-----011000010111000001101001--\r\n");
CURLcode ret = curl_easy_perform(hnd);
(require '[clj-http.client :as client])
(client/post "{{baseUrl}}/createNewStickerSet" {:multipart [{:name "contains_masks"
:content ""} {:name "emojis"
:content ""} {:name "mask_position"
:content ""} {:name "name"
:content ""} {:name "png_sticker"
:content ""} {:name "tgs_sticker"
:content ""} {:name "title"
:content ""} {:name "user_id"
:content ""}]})
require "http/client"
url = "{{baseUrl}}/createNewStickerSet"
headers = HTTP::Headers{
"content-type" => "multipart/form-data; boundary=---011000010111000001101001"
}
reqBody = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"contains_masks\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"emojis\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"mask_position\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"name\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"png_sticker\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"tgs_sticker\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"title\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"user_id\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"
response = HTTP::Client.post url, headers: headers, body: reqBody
puts response.body
using System.Net.Http.Headers;
var client = new HttpClient();
var request = new HttpRequestMessage
{
Method = HttpMethod.Post,
RequestUri = new Uri("{{baseUrl}}/createNewStickerSet"),
Content = new MultipartFormDataContent
{
new StringContent("")
{
Headers =
{
ContentDisposition = new ContentDispositionHeaderValue("form-data")
{
Name = "contains_masks",
}
}
},
new StringContent("")
{
Headers =
{
ContentDisposition = new ContentDispositionHeaderValue("form-data")
{
Name = "emojis",
}
}
},
new StringContent("")
{
Headers =
{
ContentDisposition = new ContentDispositionHeaderValue("form-data")
{
Name = "mask_position",
}
}
},
new StringContent("")
{
Headers =
{
ContentDisposition = new ContentDispositionHeaderValue("form-data")
{
Name = "name",
}
}
},
new StringContent("")
{
Headers =
{
ContentDisposition = new ContentDispositionHeaderValue("form-data")
{
Name = "png_sticker",
}
}
},
new StringContent("")
{
Headers =
{
ContentDisposition = new ContentDispositionHeaderValue("form-data")
{
Name = "tgs_sticker",
}
}
},
new StringContent("")
{
Headers =
{
ContentDisposition = new ContentDispositionHeaderValue("form-data")
{
Name = "title",
}
}
},
new StringContent("")
{
Headers =
{
ContentDisposition = new ContentDispositionHeaderValue("form-data")
{
Name = "user_id",
}
}
},
},
};
using (var response = await client.SendAsync(request))
{
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
}
var client = new RestClient("{{baseUrl}}/createNewStickerSet");
var request = new RestRequest("", Method.Post);
request.AddHeader("content-type", "multipart/form-data; boundary=---011000010111000001101001");
request.AddParameter("multipart/form-data; boundary=---011000010111000001101001", "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"contains_masks\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"emojis\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"mask_position\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"name\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"png_sticker\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"tgs_sticker\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"title\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"user_id\"\r\n\r\n\r\n-----011000010111000001101001--\r\n", ParameterType.RequestBody);
var response = client.Execute(request);
package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "{{baseUrl}}/createNewStickerSet"
payload := strings.NewReader("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"contains_masks\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"emojis\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"mask_position\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"name\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"png_sticker\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"tgs_sticker\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"title\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"user_id\"\r\n\r\n\r\n-----011000010111000001101001--\r\n")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("content-type", "multipart/form-data; boundary=---011000010111000001101001")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
POST /baseUrl/createNewStickerSet HTTP/1.1
Content-Type: multipart/form-data; boundary=---011000010111000001101001
Host: example.com
Content-Length: 712
-----011000010111000001101001
Content-Disposition: form-data; name="contains_masks"
-----011000010111000001101001
Content-Disposition: form-data; name="emojis"
-----011000010111000001101001
Content-Disposition: form-data; name="mask_position"
-----011000010111000001101001
Content-Disposition: form-data; name="name"
-----011000010111000001101001
Content-Disposition: form-data; name="png_sticker"
-----011000010111000001101001
Content-Disposition: form-data; name="tgs_sticker"
-----011000010111000001101001
Content-Disposition: form-data; name="title"
-----011000010111000001101001
Content-Disposition: form-data; name="user_id"
-----011000010111000001101001--
AsyncHttpClient client = new DefaultAsyncHttpClient();
client.prepare("POST", "{{baseUrl}}/createNewStickerSet")
.setHeader("content-type", "multipart/form-data; boundary=---011000010111000001101001")
.setBody("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"contains_masks\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"emojis\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"mask_position\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"name\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"png_sticker\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"tgs_sticker\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"title\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"user_id\"\r\n\r\n\r\n-----011000010111000001101001--\r\n")
.execute()
.toCompletableFuture()
.thenAccept(System.out::println)
.join();
client.close();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("{{baseUrl}}/createNewStickerSet"))
.header("content-type", "multipart/form-data; boundary=---011000010111000001101001")
.method("POST", HttpRequest.BodyPublishers.ofString("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"contains_masks\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"emojis\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"mask_position\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"name\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"png_sticker\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"tgs_sticker\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"title\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"user_id\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"))
.build();
HttpResponse response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("multipart/form-data; boundary=---011000010111000001101001");
RequestBody body = RequestBody.create(mediaType, "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"contains_masks\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"emojis\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"mask_position\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"name\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"png_sticker\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"tgs_sticker\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"title\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"user_id\"\r\n\r\n\r\n-----011000010111000001101001--\r\n");
Request request = new Request.Builder()
.url("{{baseUrl}}/createNewStickerSet")
.post(body)
.addHeader("content-type", "multipart/form-data; boundary=---011000010111000001101001")
.build();
Response response = client.newCall(request).execute();
HttpResponse response = Unirest.post("{{baseUrl}}/createNewStickerSet")
.header("content-type", "multipart/form-data; boundary=---011000010111000001101001")
.body("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"contains_masks\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"emojis\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"mask_position\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"name\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"png_sticker\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"tgs_sticker\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"title\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"user_id\"\r\n\r\n\r\n-----011000010111000001101001--\r\n")
.asString();
const data = new FormData();
data.append('contains_masks', '');
data.append('emojis', '');
data.append('mask_position', '');
data.append('name', '');
data.append('png_sticker', '');
data.append('tgs_sticker', '');
data.append('title', '');
data.append('user_id', '');
const xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener('readystatechange', function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open('POST', '{{baseUrl}}/createNewStickerSet');
xhr.send(data);
import axios from 'axios';
const form = new FormData();
form.append('contains_masks', '');
form.append('emojis', '');
form.append('mask_position', '');
form.append('name', '');
form.append('png_sticker', '');
form.append('tgs_sticker', '');
form.append('title', '');
form.append('user_id', '');
const options = {
method: 'POST',
url: '{{baseUrl}}/createNewStickerSet',
headers: {'content-type': 'multipart/form-data; boundary=---011000010111000001101001'},
data: '[form]'
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const url = '{{baseUrl}}/createNewStickerSet';
const form = new FormData();
form.append('contains_masks', '');
form.append('emojis', '');
form.append('mask_position', '');
form.append('name', '');
form.append('png_sticker', '');
form.append('tgs_sticker', '');
form.append('title', '');
form.append('user_id', '');
const options = {method: 'POST'};
options.body = form;
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
const form = new FormData();
form.append('contains_masks', '');
form.append('emojis', '');
form.append('mask_position', '');
form.append('name', '');
form.append('png_sticker', '');
form.append('tgs_sticker', '');
form.append('title', '');
form.append('user_id', '');
const settings = {
async: true,
crossDomain: true,
url: '{{baseUrl}}/createNewStickerSet',
method: 'POST',
headers: {},
processData: false,
contentType: false,
mimeType: 'multipart/form-data',
data: form
};
$.ajax(settings).done(function (response) {
console.log(response);
});
val client = OkHttpClient()
val mediaType = MediaType.parse("multipart/form-data; boundary=---011000010111000001101001")
val body = RequestBody.create(mediaType, "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"contains_masks\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"emojis\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"mask_position\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"name\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"png_sticker\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"tgs_sticker\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"title\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"user_id\"\r\n\r\n\r\n-----011000010111000001101001--\r\n")
val request = Request.Builder()
.url("{{baseUrl}}/createNewStickerSet")
.post(body)
.addHeader("content-type", "multipart/form-data; boundary=---011000010111000001101001")
.build()
val response = client.newCall(request).execute()
const http = require('https');
const options = {
method: 'POST',
hostname: 'example.com',
port: null,
path: '/baseUrl/createNewStickerSet',
headers: {
'content-type': 'multipart/form-data; boundary=---011000010111000001101001'
}
};
const req = http.request(options, function (res) {
const chunks = [];
res.on('data', function (chunk) {
chunks.push(chunk);
});
res.on('end', function () {
const body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.write('-----011000010111000001101001\r\nContent-Disposition: form-data; name="contains_masks"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name="emojis"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name="mask_position"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name="name"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name="png_sticker"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name="tgs_sticker"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name="title"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name="user_id"\r\n\r\n\r\n-----011000010111000001101001--\r\n');
req.end();
const request = require('request');
const options = {
method: 'POST',
url: '{{baseUrl}}/createNewStickerSet',
headers: {'content-type': 'multipart/form-data; boundary=---011000010111000001101001'},
formData: {
contains_masks: '',
emojis: '',
mask_position: '',
name: '',
png_sticker: '',
tgs_sticker: '',
title: '',
user_id: ''
}
};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
const unirest = require('unirest');
const req = unirest('POST', '{{baseUrl}}/createNewStickerSet');
req.headers({
'content-type': 'multipart/form-data; boundary=---011000010111000001101001'
});
req.multipart([]);
req.end(function (res) {
if (res.error) throw new Error(res.error);
console.log(res.body);
});
const axios = require('axios').default;
const options = {
method: 'POST',
url: '{{baseUrl}}/createNewStickerSet',
headers: {'content-type': 'multipart/form-data; boundary=---011000010111000001101001'},
data: '-----011000010111000001101001\r\nContent-Disposition: form-data; name="contains_masks"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name="emojis"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name="mask_position"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name="name"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name="png_sticker"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name="tgs_sticker"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name="title"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name="user_id"\r\n\r\n\r\n-----011000010111000001101001--\r\n'
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const FormData = require('form-data');
const fetch = require('node-fetch');
const formData = new FormData();
formData.append('contains_masks', '');
formData.append('emojis', '');
formData.append('mask_position', '');
formData.append('name', '');
formData.append('png_sticker', '');
formData.append('tgs_sticker', '');
formData.append('title', '');
formData.append('user_id', '');
const url = '{{baseUrl}}/createNewStickerSet';
const options = {method: 'POST'};
options.body = formData;
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
#import
NSDictionary *headers = @{ @"content-type": @"multipart/form-data; boundary=---011000010111000001101001" };
NSArray *parameters = @[ @{ @"name": @"contains_masks", @"value": @"" },
@{ @"name": @"emojis", @"value": @"" },
@{ @"name": @"mask_position", @"value": @"" },
@{ @"name": @"name", @"value": @"" },
@{ @"name": @"png_sticker", @"value": @"" },
@{ @"name": @"tgs_sticker", @"value": @"" },
@{ @"name": @"title", @"value": @"" },
@{ @"name": @"user_id", @"value": @"" } ];
NSString *boundary = @"---011000010111000001101001";
NSError *error;
NSMutableString *body = [NSMutableString string];
for (NSDictionary *param in parameters) {
[body appendFormat:@"--%@\r\n", boundary];
if (param[@"fileName"]) {
[body appendFormat:@"Content-Disposition:form-data; name=\"%@\"; filename=\"%@\"\r\n", param[@"name"], param[@"fileName"]];
[body appendFormat:@"Content-Type: %@\r\n\r\n", param[@"contentType"]];
[body appendFormat:@"%@", [NSString stringWithContentsOfFile:param[@"fileName"] encoding:NSUTF8StringEncoding error:&error]];
if (error) {
NSLog(@"%@", error);
}
} else {
[body appendFormat:@"Content-Disposition:form-data; name=\"%@\"\r\n\r\n", param[@"name"]];
[body appendFormat:@"%@", param[@"value"]];
}
}
[body appendFormat:@"\r\n--%@--\r\n", boundary];
NSData *postData = [body dataUsingEncoding:NSUTF8StringEncoding];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"{{baseUrl}}/createNewStickerSet"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
[request setHTTPMethod:@"POST"];
[request setAllHTTPHeaderFields:headers];
[request setHTTPBody:postData];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSLog(@"%@", httpResponse);
}
}];
[dataTask resume];
open Cohttp_lwt_unix
open Cohttp
open Lwt
let uri = Uri.of_string "{{baseUrl}}/createNewStickerSet" in
let headers = Header.add (Header.init ()) "content-type" "multipart/form-data; boundary=---011000010111000001101001" in
let body = Cohttp_lwt_body.of_string "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"contains_masks\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"emojis\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"mask_position\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"name\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"png_sticker\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"tgs_sticker\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"title\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"user_id\"\r\n\r\n\r\n-----011000010111000001101001--\r\n" in
Client.call ~headers ~body `POST uri
>>= fun (res, body_stream) ->
(* Do stuff with the result *)
"{{baseUrl}}/createNewStickerSet",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"contains_masks\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"emojis\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"mask_position\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"name\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"png_sticker\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"tgs_sticker\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"title\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"user_id\"\r\n\r\n\r\n-----011000010111000001101001--\r\n",
CURLOPT_HTTPHEADER => [
"content-type: multipart/form-data; boundary=---011000010111000001101001"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
request('POST', '{{baseUrl}}/createNewStickerSet', [
'headers' => [
'content-type' => 'multipart/form-data; boundary=---011000010111000001101001',
],
]);
echo $response->getBody();
setUrl('{{baseUrl}}/createNewStickerSet');
$request->setMethod(HTTP_METH_POST);
$request->setHeaders([
'content-type' => 'multipart/form-data; boundary=---011000010111000001101001'
]);
$request->setBody('-----011000010111000001101001
Content-Disposition: form-data; name="contains_masks"
-----011000010111000001101001
Content-Disposition: form-data; name="emojis"
-----011000010111000001101001
Content-Disposition: form-data; name="mask_position"
-----011000010111000001101001
Content-Disposition: form-data; name="name"
-----011000010111000001101001
Content-Disposition: form-data; name="png_sticker"
-----011000010111000001101001
Content-Disposition: form-data; name="tgs_sticker"
-----011000010111000001101001
Content-Disposition: form-data; name="title"
-----011000010111000001101001
Content-Disposition: form-data; name="user_id"
-----011000010111000001101001--
');
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
addForm(null, null);
$request->setRequestUrl('{{baseUrl}}/createNewStickerSet');
$request->setRequestMethod('POST');
$request->setBody($body);
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
$headers=@{}
$headers.Add("content-type", "multipart/form-data; boundary=---011000010111000001101001")
$response = Invoke-WebRequest -Uri '{{baseUrl}}/createNewStickerSet' -Method POST -Headers $headers -ContentType 'multipart/form-data; boundary=---011000010111000001101001' -Body '-----011000010111000001101001
Content-Disposition: form-data; name="contains_masks"
-----011000010111000001101001
Content-Disposition: form-data; name="emojis"
-----011000010111000001101001
Content-Disposition: form-data; name="mask_position"
-----011000010111000001101001
Content-Disposition: form-data; name="name"
-----011000010111000001101001
Content-Disposition: form-data; name="png_sticker"
-----011000010111000001101001
Content-Disposition: form-data; name="tgs_sticker"
-----011000010111000001101001
Content-Disposition: form-data; name="title"
-----011000010111000001101001
Content-Disposition: form-data; name="user_id"
-----011000010111000001101001--
'
$headers=@{}
$headers.Add("content-type", "multipart/form-data; boundary=---011000010111000001101001")
$response = Invoke-RestMethod -Uri '{{baseUrl}}/createNewStickerSet' -Method POST -Headers $headers -ContentType 'multipart/form-data; boundary=---011000010111000001101001' -Body '-----011000010111000001101001
Content-Disposition: form-data; name="contains_masks"
-----011000010111000001101001
Content-Disposition: form-data; name="emojis"
-----011000010111000001101001
Content-Disposition: form-data; name="mask_position"
-----011000010111000001101001
Content-Disposition: form-data; name="name"
-----011000010111000001101001
Content-Disposition: form-data; name="png_sticker"
-----011000010111000001101001
Content-Disposition: form-data; name="tgs_sticker"
-----011000010111000001101001
Content-Disposition: form-data; name="title"
-----011000010111000001101001
Content-Disposition: form-data; name="user_id"
-----011000010111000001101001--
'
import http.client
conn = http.client.HTTPSConnection("example.com")
payload = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"contains_masks\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"emojis\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"mask_position\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"name\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"png_sticker\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"tgs_sticker\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"title\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"user_id\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"
headers = { 'content-type': "multipart/form-data; boundary=---011000010111000001101001" }
conn.request("POST", "/baseUrl/createNewStickerSet", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
import requests
url = "{{baseUrl}}/createNewStickerSet"
payload = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"contains_masks\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"emojis\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"mask_position\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"name\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"png_sticker\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"tgs_sticker\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"title\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"user_id\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"
headers = {"content-type": "multipart/form-data; boundary=---011000010111000001101001"}
response = requests.post(url, data=payload, headers=headers)
print(response.json())
library(httr)
url <- "{{baseUrl}}/createNewStickerSet"
payload <- "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"contains_masks\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"emojis\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"mask_position\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"name\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"png_sticker\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"tgs_sticker\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"title\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"user_id\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"
encode <- "multipart"
response <- VERB("POST", url, body = payload, content_type("multipart/form-data"), encode = encode)
content(response, "text")
require 'uri'
require 'net/http'
url = URI("{{baseUrl}}/createNewStickerSet")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["content-type"] = 'multipart/form-data; boundary=---011000010111000001101001'
request.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"contains_masks\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"emojis\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"mask_position\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"name\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"png_sticker\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"tgs_sticker\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"title\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"user_id\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"
response = http.request(request)
puts response.read_body
require 'faraday'
conn = Faraday.new(
url: 'https://example.com',
headers: {'Content-Type' => 'multipart/form-data; boundary=---011000010111000001101001'}
)
response = conn.post('/baseUrl/createNewStickerSet') do |req|
req.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"contains_masks\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"emojis\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"mask_position\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"name\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"png_sticker\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"tgs_sticker\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"title\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"user_id\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"
end
puts response.status
puts response.body
use reqwest;
#[tokio::main]
pub async fn main() {
let url = "{{baseUrl}}/createNewStickerSet";
let form = reqwest::multipart::Form::new()
.text("contains_masks", "")
.text("emojis", "")
.text("mask_position", "")
.text("name", "")
.text("png_sticker", "")
.text("tgs_sticker", "")
.text("title", "")
.text("user_id", "");
let mut headers = reqwest::header::HeaderMap::new();
let client = reqwest::Client::new();
let response = client.post(url)
.multipart(form)
.headers(headers)
.send()
.await;
let results = response.unwrap()
.json::()
.await
.unwrap();
dbg!(results);
}
curl --request POST \
--url {{baseUrl}}/createNewStickerSet \
--header 'content-type: multipart/form-data' \
--form contains_masks= \
--form emojis= \
--form mask_position= \
--form name= \
--form png_sticker= \
--form tgs_sticker= \
--form title= \
--form user_id=
echo '-----011000010111000001101001
Content-Disposition: form-data; name="contains_masks"
-----011000010111000001101001
Content-Disposition: form-data; name="emojis"
-----011000010111000001101001
Content-Disposition: form-data; name="mask_position"
-----011000010111000001101001
Content-Disposition: form-data; name="name"
-----011000010111000001101001
Content-Disposition: form-data; name="png_sticker"
-----011000010111000001101001
Content-Disposition: form-data; name="tgs_sticker"
-----011000010111000001101001
Content-Disposition: form-data; name="title"
-----011000010111000001101001
Content-Disposition: form-data; name="user_id"
-----011000010111000001101001--
' | \
http POST {{baseUrl}}/createNewStickerSet \
content-type:'multipart/form-data; boundary=---011000010111000001101001'
wget --quiet \
--method POST \
--header 'content-type: multipart/form-data; boundary=---011000010111000001101001' \
--body-data '-----011000010111000001101001\r\nContent-Disposition: form-data; name="contains_masks"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name="emojis"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name="mask_position"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name="name"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name="png_sticker"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name="tgs_sticker"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name="title"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name="user_id"\r\n\r\n\r\n-----011000010111000001101001--\r\n' \
--output-document \
- {{baseUrl}}/createNewStickerSet
import Foundation
let headers = ["content-type": "multipart/form-data; boundary=---011000010111000001101001"]
let parameters = [
[
"name": "contains_masks",
"value": ""
],
[
"name": "emojis",
"value": ""
],
[
"name": "mask_position",
"value": ""
],
[
"name": "name",
"value": ""
],
[
"name": "png_sticker",
"value": ""
],
[
"name": "tgs_sticker",
"value": ""
],
[
"name": "title",
"value": ""
],
[
"name": "user_id",
"value": ""
]
]
let boundary = "---011000010111000001101001"
var body = ""
var error: NSError? = nil
for param in parameters {
let paramName = param["name"]!
body += "--\(boundary)\r\n"
body += "Content-Disposition:form-data; name=\"\(paramName)\""
if let filename = param["fileName"] {
let contentType = param["content-type"]!
let fileContent = String(contentsOfFile: filename, encoding: String.Encoding.utf8)
if (error != nil) {
print(error as Any)
}
body += "; filename=\"\(filename)\"\r\n"
body += "Content-Type: \(contentType)\r\n\r\n"
body += fileContent
} else if let paramValue = param["value"] {
body += "\r\n\r\n\(paramValue)"
}
}
let request = NSMutableURLRequest(url: NSURL(string: "{{baseUrl}}/createNewStickerSet")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error as Any)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
POST
Use this method to delete a chat photo. Photos can't be changed for private chats. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Returns -True- on success.
{{baseUrl}}/deleteChatPhoto
BODY json
{
"chat_id": ""
}
Examples
REQUEST
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(hnd, CURLOPT_URL, "{{baseUrl}}/deleteChatPhoto");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "content-type: application/json");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "{\n \"chat_id\": \"\"\n}");
CURLcode ret = curl_easy_perform(hnd);
(require '[clj-http.client :as client])
(client/post "{{baseUrl}}/deleteChatPhoto" {:content-type :json
:form-params {:chat_id ""}})
require "http/client"
url = "{{baseUrl}}/deleteChatPhoto"
headers = HTTP::Headers{
"content-type" => "application/json"
}
reqBody = "{\n \"chat_id\": \"\"\n}"
response = HTTP::Client.post url, headers: headers, body: reqBody
puts response.body
using System.Net.Http.Headers;
var client = new HttpClient();
var request = new HttpRequestMessage
{
Method = HttpMethod.Post,
RequestUri = new Uri("{{baseUrl}}/deleteChatPhoto"),
Content = new StringContent("{\n \"chat_id\": \"\"\n}")
{
Headers =
{
ContentType = new MediaTypeHeaderValue("application/json")
}
}
};
using (var response = await client.SendAsync(request))
{
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
}
var client = new RestClient("{{baseUrl}}/deleteChatPhoto");
var request = new RestRequest("", Method.Post);
request.AddHeader("content-type", "application/json");
request.AddParameter("application/json", "{\n \"chat_id\": \"\"\n}", ParameterType.RequestBody);
var response = client.Execute(request);
package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "{{baseUrl}}/deleteChatPhoto"
payload := strings.NewReader("{\n \"chat_id\": \"\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("content-type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
POST /baseUrl/deleteChatPhoto HTTP/1.1
Content-Type: application/json
Host: example.com
Content-Length: 19
{
"chat_id": ""
}
AsyncHttpClient client = new DefaultAsyncHttpClient();
client.prepare("POST", "{{baseUrl}}/deleteChatPhoto")
.setHeader("content-type", "application/json")
.setBody("{\n \"chat_id\": \"\"\n}")
.execute()
.toCompletableFuture()
.thenAccept(System.out::println)
.join();
client.close();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("{{baseUrl}}/deleteChatPhoto"))
.header("content-type", "application/json")
.method("POST", HttpRequest.BodyPublishers.ofString("{\n \"chat_id\": \"\"\n}"))
.build();
HttpResponse response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n \"chat_id\": \"\"\n}");
Request request = new Request.Builder()
.url("{{baseUrl}}/deleteChatPhoto")
.post(body)
.addHeader("content-type", "application/json")
.build();
Response response = client.newCall(request).execute();
HttpResponse response = Unirest.post("{{baseUrl}}/deleteChatPhoto")
.header("content-type", "application/json")
.body("{\n \"chat_id\": \"\"\n}")
.asString();
const data = JSON.stringify({
chat_id: ''
});
const xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener('readystatechange', function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open('POST', '{{baseUrl}}/deleteChatPhoto');
xhr.setRequestHeader('content-type', 'application/json');
xhr.send(data);
import axios from 'axios';
const options = {
method: 'POST',
url: '{{baseUrl}}/deleteChatPhoto',
headers: {'content-type': 'application/json'},
data: {chat_id: ''}
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const url = '{{baseUrl}}/deleteChatPhoto';
const options = {
method: 'POST',
headers: {'content-type': 'application/json'},
body: '{"chat_id":""}'
};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
const settings = {
async: true,
crossDomain: true,
url: '{{baseUrl}}/deleteChatPhoto',
method: 'POST',
headers: {
'content-type': 'application/json'
},
processData: false,
data: '{\n "chat_id": ""\n}'
};
$.ajax(settings).done(function (response) {
console.log(response);
});
val client = OkHttpClient()
val mediaType = MediaType.parse("application/json")
val body = RequestBody.create(mediaType, "{\n \"chat_id\": \"\"\n}")
val request = Request.Builder()
.url("{{baseUrl}}/deleteChatPhoto")
.post(body)
.addHeader("content-type", "application/json")
.build()
val response = client.newCall(request).execute()
const http = require('https');
const options = {
method: 'POST',
hostname: 'example.com',
port: null,
path: '/baseUrl/deleteChatPhoto',
headers: {
'content-type': 'application/json'
}
};
const req = http.request(options, function (res) {
const chunks = [];
res.on('data', function (chunk) {
chunks.push(chunk);
});
res.on('end', function () {
const body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.write(JSON.stringify({chat_id: ''}));
req.end();
const request = require('request');
const options = {
method: 'POST',
url: '{{baseUrl}}/deleteChatPhoto',
headers: {'content-type': 'application/json'},
body: {chat_id: ''},
json: true
};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
const unirest = require('unirest');
const req = unirest('POST', '{{baseUrl}}/deleteChatPhoto');
req.headers({
'content-type': 'application/json'
});
req.type('json');
req.send({
chat_id: ''
});
req.end(function (res) {
if (res.error) throw new Error(res.error);
console.log(res.body);
});
const axios = require('axios').default;
const options = {
method: 'POST',
url: '{{baseUrl}}/deleteChatPhoto',
headers: {'content-type': 'application/json'},
data: {chat_id: ''}
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const fetch = require('node-fetch');
const url = '{{baseUrl}}/deleteChatPhoto';
const options = {
method: 'POST',
headers: {'content-type': 'application/json'},
body: '{"chat_id":""}'
};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
#import
NSDictionary *headers = @{ @"content-type": @"application/json" };
NSDictionary *parameters = @{ @"chat_id": @"" };
NSData *postData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"{{baseUrl}}/deleteChatPhoto"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
[request setHTTPMethod:@"POST"];
[request setAllHTTPHeaderFields:headers];
[request setHTTPBody:postData];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSLog(@"%@", httpResponse);
}
}];
[dataTask resume];
open Cohttp_lwt_unix
open Cohttp
open Lwt
let uri = Uri.of_string "{{baseUrl}}/deleteChatPhoto" in
let headers = Header.add (Header.init ()) "content-type" "application/json" in
let body = Cohttp_lwt_body.of_string "{\n \"chat_id\": \"\"\n}" in
Client.call ~headers ~body `POST uri
>>= fun (res, body_stream) ->
(* Do stuff with the result *)
"{{baseUrl}}/deleteChatPhoto",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'chat_id' => ''
]),
CURLOPT_HTTPHEADER => [
"content-type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
request('POST', '{{baseUrl}}/deleteChatPhoto', [
'body' => '{
"chat_id": ""
}',
'headers' => [
'content-type' => 'application/json',
],
]);
echo $response->getBody();
setUrl('{{baseUrl}}/deleteChatPhoto');
$request->setMethod(HTTP_METH_POST);
$request->setHeaders([
'content-type' => 'application/json'
]);
$request->setContentType('application/json');
$request->setBody(json_encode([
'chat_id' => ''
]));
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
append(json_encode([
'chat_id' => ''
]));
$request->setRequestUrl('{{baseUrl}}/deleteChatPhoto');
$request->setRequestMethod('POST');
$request->setBody($body);
$request->setHeaders([
'content-type' => 'application/json'
]);
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
$headers=@{}
$headers.Add("content-type", "application/json")
$response = Invoke-WebRequest -Uri '{{baseUrl}}/deleteChatPhoto' -Method POST -Headers $headers -ContentType 'application/json' -Body '{
"chat_id": ""
}'
$headers=@{}
$headers.Add("content-type", "application/json")
$response = Invoke-RestMethod -Uri '{{baseUrl}}/deleteChatPhoto' -Method POST -Headers $headers -ContentType 'application/json' -Body '{
"chat_id": ""
}'
import http.client
conn = http.client.HTTPSConnection("example.com")
payload = "{\n \"chat_id\": \"\"\n}"
headers = { 'content-type': "application/json" }
conn.request("POST", "/baseUrl/deleteChatPhoto", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
import requests
url = "{{baseUrl}}/deleteChatPhoto"
payload = { "chat_id": "" }
headers = {"content-type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
library(httr)
url <- "{{baseUrl}}/deleteChatPhoto"
payload <- "{\n \"chat_id\": \"\"\n}"
encode <- "json"
response <- VERB("POST", url, body = payload, content_type("application/json"), encode = encode)
content(response, "text")
require 'uri'
require 'net/http'
url = URI("{{baseUrl}}/deleteChatPhoto")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["content-type"] = 'application/json'
request.body = "{\n \"chat_id\": \"\"\n}"
response = http.request(request)
puts response.read_body
require 'faraday'
conn = Faraday.new(
url: 'https://example.com',
headers: {'Content-Type' => 'application/json'}
)
response = conn.post('/baseUrl/deleteChatPhoto') do |req|
req.body = "{\n \"chat_id\": \"\"\n}"
end
puts response.status
puts response.body
use serde_json::json;
use reqwest;
#[tokio::main]
pub async fn main() {
let url = "{{baseUrl}}/deleteChatPhoto";
let payload = json!({"chat_id": ""});
let mut headers = reqwest::header::HeaderMap::new();
headers.insert("content-type", "application/json".parse().unwrap());
let client = reqwest::Client::new();
let response = client.post(url)
.headers(headers)
.json(&payload)
.send()
.await;
let results = response.unwrap()
.json::()
.await
.unwrap();
dbg!(results);
}
curl --request POST \
--url {{baseUrl}}/deleteChatPhoto \
--header 'content-type: application/json' \
--data '{
"chat_id": ""
}'
echo '{
"chat_id": ""
}' | \
http POST {{baseUrl}}/deleteChatPhoto \
content-type:application/json
wget --quiet \
--method POST \
--header 'content-type: application/json' \
--body-data '{\n "chat_id": ""\n}' \
--output-document \
- {{baseUrl}}/deleteChatPhoto
import Foundation
let headers = ["content-type": "application/json"]
let parameters = ["chat_id": ""] as [String : Any]
let postData = JSONSerialization.data(withJSONObject: parameters, options: [])
let request = NSMutableURLRequest(url: NSURL(string: "{{baseUrl}}/deleteChatPhoto")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error as Any)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
POST
Use this method to delete a sticker from a set created by the bot. Returns -True- on success.
{{baseUrl}}/deleteStickerFromSet
BODY json
{
"sticker": ""
}
Examples
REQUEST
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(hnd, CURLOPT_URL, "{{baseUrl}}/deleteStickerFromSet");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "content-type: application/json");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "{\n \"sticker\": \"\"\n}");
CURLcode ret = curl_easy_perform(hnd);
(require '[clj-http.client :as client])
(client/post "{{baseUrl}}/deleteStickerFromSet" {:content-type :json
:form-params {:sticker ""}})
require "http/client"
url = "{{baseUrl}}/deleteStickerFromSet"
headers = HTTP::Headers{
"content-type" => "application/json"
}
reqBody = "{\n \"sticker\": \"\"\n}"
response = HTTP::Client.post url, headers: headers, body: reqBody
puts response.body
using System.Net.Http.Headers;
var client = new HttpClient();
var request = new HttpRequestMessage
{
Method = HttpMethod.Post,
RequestUri = new Uri("{{baseUrl}}/deleteStickerFromSet"),
Content = new StringContent("{\n \"sticker\": \"\"\n}")
{
Headers =
{
ContentType = new MediaTypeHeaderValue("application/json")
}
}
};
using (var response = await client.SendAsync(request))
{
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
}
var client = new RestClient("{{baseUrl}}/deleteStickerFromSet");
var request = new RestRequest("", Method.Post);
request.AddHeader("content-type", "application/json");
request.AddParameter("application/json", "{\n \"sticker\": \"\"\n}", ParameterType.RequestBody);
var response = client.Execute(request);
package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "{{baseUrl}}/deleteStickerFromSet"
payload := strings.NewReader("{\n \"sticker\": \"\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("content-type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
POST /baseUrl/deleteStickerFromSet HTTP/1.1
Content-Type: application/json
Host: example.com
Content-Length: 19
{
"sticker": ""
}
AsyncHttpClient client = new DefaultAsyncHttpClient();
client.prepare("POST", "{{baseUrl}}/deleteStickerFromSet")
.setHeader("content-type", "application/json")
.setBody("{\n \"sticker\": \"\"\n}")
.execute()
.toCompletableFuture()
.thenAccept(System.out::println)
.join();
client.close();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("{{baseUrl}}/deleteStickerFromSet"))
.header("content-type", "application/json")
.method("POST", HttpRequest.BodyPublishers.ofString("{\n \"sticker\": \"\"\n}"))
.build();
HttpResponse response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n \"sticker\": \"\"\n}");
Request request = new Request.Builder()
.url("{{baseUrl}}/deleteStickerFromSet")
.post(body)
.addHeader("content-type", "application/json")
.build();
Response response = client.newCall(request).execute();
HttpResponse response = Unirest.post("{{baseUrl}}/deleteStickerFromSet")
.header("content-type", "application/json")
.body("{\n \"sticker\": \"\"\n}")
.asString();
const data = JSON.stringify({
sticker: ''
});
const xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener('readystatechange', function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open('POST', '{{baseUrl}}/deleteStickerFromSet');
xhr.setRequestHeader('content-type', 'application/json');
xhr.send(data);
import axios from 'axios';
const options = {
method: 'POST',
url: '{{baseUrl}}/deleteStickerFromSet',
headers: {'content-type': 'application/json'},
data: {sticker: ''}
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const url = '{{baseUrl}}/deleteStickerFromSet';
const options = {
method: 'POST',
headers: {'content-type': 'application/json'},
body: '{"sticker":""}'
};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
const settings = {
async: true,
crossDomain: true,
url: '{{baseUrl}}/deleteStickerFromSet',
method: 'POST',
headers: {
'content-type': 'application/json'
},
processData: false,
data: '{\n "sticker": ""\n}'
};
$.ajax(settings).done(function (response) {
console.log(response);
});
val client = OkHttpClient()
val mediaType = MediaType.parse("application/json")
val body = RequestBody.create(mediaType, "{\n \"sticker\": \"\"\n}")
val request = Request.Builder()
.url("{{baseUrl}}/deleteStickerFromSet")
.post(body)
.addHeader("content-type", "application/json")
.build()
val response = client.newCall(request).execute()
const http = require('https');
const options = {
method: 'POST',
hostname: 'example.com',
port: null,
path: '/baseUrl/deleteStickerFromSet',
headers: {
'content-type': 'application/json'
}
};
const req = http.request(options, function (res) {
const chunks = [];
res.on('data', function (chunk) {
chunks.push(chunk);
});
res.on('end', function () {
const body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.write(JSON.stringify({sticker: ''}));
req.end();
const request = require('request');
const options = {
method: 'POST',
url: '{{baseUrl}}/deleteStickerFromSet',
headers: {'content-type': 'application/json'},
body: {sticker: ''},
json: true
};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
const unirest = require('unirest');
const req = unirest('POST', '{{baseUrl}}/deleteStickerFromSet');
req.headers({
'content-type': 'application/json'
});
req.type('json');
req.send({
sticker: ''
});
req.end(function (res) {
if (res.error) throw new Error(res.error);
console.log(res.body);
});
const axios = require('axios').default;
const options = {
method: 'POST',
url: '{{baseUrl}}/deleteStickerFromSet',
headers: {'content-type': 'application/json'},
data: {sticker: ''}
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const fetch = require('node-fetch');
const url = '{{baseUrl}}/deleteStickerFromSet';
const options = {
method: 'POST',
headers: {'content-type': 'application/json'},
body: '{"sticker":""}'
};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
#import
NSDictionary *headers = @{ @"content-type": @"application/json" };
NSDictionary *parameters = @{ @"sticker": @"" };
NSData *postData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"{{baseUrl}}/deleteStickerFromSet"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
[request setHTTPMethod:@"POST"];
[request setAllHTTPHeaderFields:headers];
[request setHTTPBody:postData];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSLog(@"%@", httpResponse);
}
}];
[dataTask resume];
open Cohttp_lwt_unix
open Cohttp
open Lwt
let uri = Uri.of_string "{{baseUrl}}/deleteStickerFromSet" in
let headers = Header.add (Header.init ()) "content-type" "application/json" in
let body = Cohttp_lwt_body.of_string "{\n \"sticker\": \"\"\n}" in
Client.call ~headers ~body `POST uri
>>= fun (res, body_stream) ->
(* Do stuff with the result *)
"{{baseUrl}}/deleteStickerFromSet",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'sticker' => ''
]),
CURLOPT_HTTPHEADER => [
"content-type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
request('POST', '{{baseUrl}}/deleteStickerFromSet', [
'body' => '{
"sticker": ""
}',
'headers' => [
'content-type' => 'application/json',
],
]);
echo $response->getBody();
setUrl('{{baseUrl}}/deleteStickerFromSet');
$request->setMethod(HTTP_METH_POST);
$request->setHeaders([
'content-type' => 'application/json'
]);
$request->setContentType('application/json');
$request->setBody(json_encode([
'sticker' => ''
]));
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
append(json_encode([
'sticker' => ''
]));
$request->setRequestUrl('{{baseUrl}}/deleteStickerFromSet');
$request->setRequestMethod('POST');
$request->setBody($body);
$request->setHeaders([
'content-type' => 'application/json'
]);
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
$headers=@{}
$headers.Add("content-type", "application/json")
$response = Invoke-WebRequest -Uri '{{baseUrl}}/deleteStickerFromSet' -Method POST -Headers $headers -ContentType 'application/json' -Body '{
"sticker": ""
}'
$headers=@{}
$headers.Add("content-type", "application/json")
$response = Invoke-RestMethod -Uri '{{baseUrl}}/deleteStickerFromSet' -Method POST -Headers $headers -ContentType 'application/json' -Body '{
"sticker": ""
}'
import http.client
conn = http.client.HTTPSConnection("example.com")
payload = "{\n \"sticker\": \"\"\n}"
headers = { 'content-type': "application/json" }
conn.request("POST", "/baseUrl/deleteStickerFromSet", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
import requests
url = "{{baseUrl}}/deleteStickerFromSet"
payload = { "sticker": "" }
headers = {"content-type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
library(httr)
url <- "{{baseUrl}}/deleteStickerFromSet"
payload <- "{\n \"sticker\": \"\"\n}"
encode <- "json"
response <- VERB("POST", url, body = payload, content_type("application/json"), encode = encode)
content(response, "text")
require 'uri'
require 'net/http'
url = URI("{{baseUrl}}/deleteStickerFromSet")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["content-type"] = 'application/json'
request.body = "{\n \"sticker\": \"\"\n}"
response = http.request(request)
puts response.read_body
require 'faraday'
conn = Faraday.new(
url: 'https://example.com',
headers: {'Content-Type' => 'application/json'}
)
response = conn.post('/baseUrl/deleteStickerFromSet') do |req|
req.body = "{\n \"sticker\": \"\"\n}"
end
puts response.status
puts response.body
use serde_json::json;
use reqwest;
#[tokio::main]
pub async fn main() {
let url = "{{baseUrl}}/deleteStickerFromSet";
let payload = json!({"sticker": ""});
let mut headers = reqwest::header::HeaderMap::new();
headers.insert("content-type", "application/json".parse().unwrap());
let client = reqwest::Client::new();
let response = client.post(url)
.headers(headers)
.json(&payload)
.send()
.await;
let results = response.unwrap()
.json::()
.await
.unwrap();
dbg!(results);
}
curl --request POST \
--url {{baseUrl}}/deleteStickerFromSet \
--header 'content-type: application/json' \
--data '{
"sticker": ""
}'
echo '{
"sticker": ""
}' | \
http POST {{baseUrl}}/deleteStickerFromSet \
content-type:application/json
wget --quiet \
--method POST \
--header 'content-type: application/json' \
--body-data '{\n "sticker": ""\n}' \
--output-document \
- {{baseUrl}}/deleteStickerFromSet
import Foundation
let headers = ["content-type": "application/json"]
let parameters = ["sticker": ""] as [String : Any]
let postData = JSONSerialization.data(withJSONObject: parameters, options: [])
let request = NSMutableURLRequest(url: NSURL(string: "{{baseUrl}}/deleteStickerFromSet")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error as Any)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
POST
Use this method to edit captions of messages. On success, if the edited message is not an inline message, the edited [Message](https---core.telegram.org-bots-api-#message) is returned, otherwise -True- is returned.
{{baseUrl}}/editMessageCaption
BODY json
{
"caption": "",
"caption_entities": [
{
"language": "",
"length": 0,
"offset": 0,
"type": "",
"url": "",
"user": {
"can_join_groups": false,
"can_read_all_group_messages": false,
"first_name": "",
"id": 0,
"is_bot": false,
"language_code": "",
"last_name": "",
"supports_inline_queries": false,
"username": ""
}
}
],
"chat_id": "",
"inline_message_id": "",
"message_id": 0,
"parse_mode": "",
"reply_markup": {
"inline_keyboard": []
}
}
Examples
REQUEST
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(hnd, CURLOPT_URL, "{{baseUrl}}/editMessageCaption");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "content-type: application/json");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "{\n \"caption\": \"\",\n \"caption_entities\": [\n {\n \"language\": \"\",\n \"length\": 0,\n \"offset\": 0,\n \"type\": \"\",\n \"url\": \"\",\n \"user\": {\n \"can_join_groups\": false,\n \"can_read_all_group_messages\": false,\n \"first_name\": \"\",\n \"id\": 0,\n \"is_bot\": false,\n \"language_code\": \"\",\n \"last_name\": \"\",\n \"supports_inline_queries\": false,\n \"username\": \"\"\n }\n }\n ],\n \"chat_id\": \"\",\n \"inline_message_id\": \"\",\n \"message_id\": 0,\n \"parse_mode\": \"\",\n \"reply_markup\": {\n \"inline_keyboard\": []\n }\n}");
CURLcode ret = curl_easy_perform(hnd);
(require '[clj-http.client :as client])
(client/post "{{baseUrl}}/editMessageCaption" {:content-type :json
:form-params {:caption ""
:caption_entities [{:language ""
:length 0
:offset 0
:type ""
:url ""
:user {:can_join_groups false
:can_read_all_group_messages false
:first_name ""
:id 0
:is_bot false
:language_code ""
:last_name ""
:supports_inline_queries false
:username ""}}]
:chat_id ""
:inline_message_id ""
:message_id 0
:parse_mode ""
:reply_markup {:inline_keyboard []}}})
require "http/client"
url = "{{baseUrl}}/editMessageCaption"
headers = HTTP::Headers{
"content-type" => "application/json"
}
reqBody = "{\n \"caption\": \"\",\n \"caption_entities\": [\n {\n \"language\": \"\",\n \"length\": 0,\n \"offset\": 0,\n \"type\": \"\",\n \"url\": \"\",\n \"user\": {\n \"can_join_groups\": false,\n \"can_read_all_group_messages\": false,\n \"first_name\": \"\",\n \"id\": 0,\n \"is_bot\": false,\n \"language_code\": \"\",\n \"last_name\": \"\",\n \"supports_inline_queries\": false,\n \"username\": \"\"\n }\n }\n ],\n \"chat_id\": \"\",\n \"inline_message_id\": \"\",\n \"message_id\": 0,\n \"parse_mode\": \"\",\n \"reply_markup\": {\n \"inline_keyboard\": []\n }\n}"
response = HTTP::Client.post url, headers: headers, body: reqBody
puts response.body
using System.Net.Http.Headers;
var client = new HttpClient();
var request = new HttpRequestMessage
{
Method = HttpMethod.Post,
RequestUri = new Uri("{{baseUrl}}/editMessageCaption"),
Content = new StringContent("{\n \"caption\": \"\",\n \"caption_entities\": [\n {\n \"language\": \"\",\n \"length\": 0,\n \"offset\": 0,\n \"type\": \"\",\n \"url\": \"\",\n \"user\": {\n \"can_join_groups\": false,\n \"can_read_all_group_messages\": false,\n \"first_name\": \"\",\n \"id\": 0,\n \"is_bot\": false,\n \"language_code\": \"\",\n \"last_name\": \"\",\n \"supports_inline_queries\": false,\n \"username\": \"\"\n }\n }\n ],\n \"chat_id\": \"\",\n \"inline_message_id\": \"\",\n \"message_id\": 0,\n \"parse_mode\": \"\",\n \"reply_markup\": {\n \"inline_keyboard\": []\n }\n}")
{
Headers =
{
ContentType = new MediaTypeHeaderValue("application/json")
}
}
};
using (var response = await client.SendAsync(request))
{
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
}
var client = new RestClient("{{baseUrl}}/editMessageCaption");
var request = new RestRequest("", Method.Post);
request.AddHeader("content-type", "application/json");
request.AddParameter("application/json", "{\n \"caption\": \"\",\n \"caption_entities\": [\n {\n \"language\": \"\",\n \"length\": 0,\n \"offset\": 0,\n \"type\": \"\",\n \"url\": \"\",\n \"user\": {\n \"can_join_groups\": false,\n \"can_read_all_group_messages\": false,\n \"first_name\": \"\",\n \"id\": 0,\n \"is_bot\": false,\n \"language_code\": \"\",\n \"last_name\": \"\",\n \"supports_inline_queries\": false,\n \"username\": \"\"\n }\n }\n ],\n \"chat_id\": \"\",\n \"inline_message_id\": \"\",\n \"message_id\": 0,\n \"parse_mode\": \"\",\n \"reply_markup\": {\n \"inline_keyboard\": []\n }\n}", ParameterType.RequestBody);
var response = client.Execute(request);
package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "{{baseUrl}}/editMessageCaption"
payload := strings.NewReader("{\n \"caption\": \"\",\n \"caption_entities\": [\n {\n \"language\": \"\",\n \"length\": 0,\n \"offset\": 0,\n \"type\": \"\",\n \"url\": \"\",\n \"user\": {\n \"can_join_groups\": false,\n \"can_read_all_group_messages\": false,\n \"first_name\": \"\",\n \"id\": 0,\n \"is_bot\": false,\n \"language_code\": \"\",\n \"last_name\": \"\",\n \"supports_inline_queries\": false,\n \"username\": \"\"\n }\n }\n ],\n \"chat_id\": \"\",\n \"inline_message_id\": \"\",\n \"message_id\": 0,\n \"parse_mode\": \"\",\n \"reply_markup\": {\n \"inline_keyboard\": []\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("content-type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
POST /baseUrl/editMessageCaption HTTP/1.1
Content-Type: application/json
Host: example.com
Content-Length: 580
{
"caption": "",
"caption_entities": [
{
"language": "",
"length": 0,
"offset": 0,
"type": "",
"url": "",
"user": {
"can_join_groups": false,
"can_read_all_group_messages": false,
"first_name": "",
"id": 0,
"is_bot": false,
"language_code": "",
"last_name": "",
"supports_inline_queries": false,
"username": ""
}
}
],
"chat_id": "",
"inline_message_id": "",
"message_id": 0,
"parse_mode": "",
"reply_markup": {
"inline_keyboard": []
}
}
AsyncHttpClient client = new DefaultAsyncHttpClient();
client.prepare("POST", "{{baseUrl}}/editMessageCaption")
.setHeader("content-type", "application/json")
.setBody("{\n \"caption\": \"\",\n \"caption_entities\": [\n {\n \"language\": \"\",\n \"length\": 0,\n \"offset\": 0,\n \"type\": \"\",\n \"url\": \"\",\n \"user\": {\n \"can_join_groups\": false,\n \"can_read_all_group_messages\": false,\n \"first_name\": \"\",\n \"id\": 0,\n \"is_bot\": false,\n \"language_code\": \"\",\n \"last_name\": \"\",\n \"supports_inline_queries\": false,\n \"username\": \"\"\n }\n }\n ],\n \"chat_id\": \"\",\n \"inline_message_id\": \"\",\n \"message_id\": 0,\n \"parse_mode\": \"\",\n \"reply_markup\": {\n \"inline_keyboard\": []\n }\n}")
.execute()
.toCompletableFuture()
.thenAccept(System.out::println)
.join();
client.close();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("{{baseUrl}}/editMessageCaption"))
.header("content-type", "application/json")
.method("POST", HttpRequest.BodyPublishers.ofString("{\n \"caption\": \"\",\n \"caption_entities\": [\n {\n \"language\": \"\",\n \"length\": 0,\n \"offset\": 0,\n \"type\": \"\",\n \"url\": \"\",\n \"user\": {\n \"can_join_groups\": false,\n \"can_read_all_group_messages\": false,\n \"first_name\": \"\",\n \"id\": 0,\n \"is_bot\": false,\n \"language_code\": \"\",\n \"last_name\": \"\",\n \"supports_inline_queries\": false,\n \"username\": \"\"\n }\n }\n ],\n \"chat_id\": \"\",\n \"inline_message_id\": \"\",\n \"message_id\": 0,\n \"parse_mode\": \"\",\n \"reply_markup\": {\n \"inline_keyboard\": []\n }\n}"))
.build();
HttpResponse response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n \"caption\": \"\",\n \"caption_entities\": [\n {\n \"language\": \"\",\n \"length\": 0,\n \"offset\": 0,\n \"type\": \"\",\n \"url\": \"\",\n \"user\": {\n \"can_join_groups\": false,\n \"can_read_all_group_messages\": false,\n \"first_name\": \"\",\n \"id\": 0,\n \"is_bot\": false,\n \"language_code\": \"\",\n \"last_name\": \"\",\n \"supports_inline_queries\": false,\n \"username\": \"\"\n }\n }\n ],\n \"chat_id\": \"\",\n \"inline_message_id\": \"\",\n \"message_id\": 0,\n \"parse_mode\": \"\",\n \"reply_markup\": {\n \"inline_keyboard\": []\n }\n}");
Request request = new Request.Builder()
.url("{{baseUrl}}/editMessageCaption")
.post(body)
.addHeader("content-type", "application/json")
.build();
Response response = client.newCall(request).execute();
HttpResponse response = Unirest.post("{{baseUrl}}/editMessageCaption")
.header("content-type", "application/json")
.body("{\n \"caption\": \"\",\n \"caption_entities\": [\n {\n \"language\": \"\",\n \"length\": 0,\n \"offset\": 0,\n \"type\": \"\",\n \"url\": \"\",\n \"user\": {\n \"can_join_groups\": false,\n \"can_read_all_group_messages\": false,\n \"first_name\": \"\",\n \"id\": 0,\n \"is_bot\": false,\n \"language_code\": \"\",\n \"last_name\": \"\",\n \"supports_inline_queries\": false,\n \"username\": \"\"\n }\n }\n ],\n \"chat_id\": \"\",\n \"inline_message_id\": \"\",\n \"message_id\": 0,\n \"parse_mode\": \"\",\n \"reply_markup\": {\n \"inline_keyboard\": []\n }\n}")
.asString();
const data = JSON.stringify({
caption: '',
caption_entities: [
{
language: '',
length: 0,
offset: 0,
type: '',
url: '',
user: {
can_join_groups: false,
can_read_all_group_messages: false,
first_name: '',
id: 0,
is_bot: false,
language_code: '',
last_name: '',
supports_inline_queries: false,
username: ''
}
}
],
chat_id: '',
inline_message_id: '',
message_id: 0,
parse_mode: '',
reply_markup: {
inline_keyboard: []
}
});
const xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener('readystatechange', function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open('POST', '{{baseUrl}}/editMessageCaption');
xhr.setRequestHeader('content-type', 'application/json');
xhr.send(data);
import axios from 'axios';
const options = {
method: 'POST',
url: '{{baseUrl}}/editMessageCaption',
headers: {'content-type': 'application/json'},
data: {
caption: '',
caption_entities: [
{
language: '',
length: 0,
offset: 0,
type: '',
url: '',
user: {
can_join_groups: false,
can_read_all_group_messages: false,
first_name: '',
id: 0,
is_bot: false,
language_code: '',
last_name: '',
supports_inline_queries: false,
username: ''
}
}
],
chat_id: '',
inline_message_id: '',
message_id: 0,
parse_mode: '',
reply_markup: {inline_keyboard: []}
}
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const url = '{{baseUrl}}/editMessageCaption';
const options = {
method: 'POST',
headers: {'content-type': 'application/json'},
body: '{"caption":"","caption_entities":[{"language":"","length":0,"offset":0,"type":"","url":"","user":{"can_join_groups":false,"can_read_all_group_messages":false,"first_name":"","id":0,"is_bot":false,"language_code":"","last_name":"","supports_inline_queries":false,"username":""}}],"chat_id":"","inline_message_id":"","message_id":0,"parse_mode":"","reply_markup":{"inline_keyboard":[]}}'
};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
const settings = {
async: true,
crossDomain: true,
url: '{{baseUrl}}/editMessageCaption',
method: 'POST',
headers: {
'content-type': 'application/json'
},
processData: false,
data: '{\n "caption": "",\n "caption_entities": [\n {\n "language": "",\n "length": 0,\n "offset": 0,\n "type": "",\n "url": "",\n "user": {\n "can_join_groups": false,\n "can_read_all_group_messages": false,\n "first_name": "",\n "id": 0,\n "is_bot": false,\n "language_code": "",\n "last_name": "",\n "supports_inline_queries": false,\n "username": ""\n }\n }\n ],\n "chat_id": "",\n "inline_message_id": "",\n "message_id": 0,\n "parse_mode": "",\n "reply_markup": {\n "inline_keyboard": []\n }\n}'
};
$.ajax(settings).done(function (response) {
console.log(response);
});
val client = OkHttpClient()
val mediaType = MediaType.parse("application/json")
val body = RequestBody.create(mediaType, "{\n \"caption\": \"\",\n \"caption_entities\": [\n {\n \"language\": \"\",\n \"length\": 0,\n \"offset\": 0,\n \"type\": \"\",\n \"url\": \"\",\n \"user\": {\n \"can_join_groups\": false,\n \"can_read_all_group_messages\": false,\n \"first_name\": \"\",\n \"id\": 0,\n \"is_bot\": false,\n \"language_code\": \"\",\n \"last_name\": \"\",\n \"supports_inline_queries\": false,\n \"username\": \"\"\n }\n }\n ],\n \"chat_id\": \"\",\n \"inline_message_id\": \"\",\n \"message_id\": 0,\n \"parse_mode\": \"\",\n \"reply_markup\": {\n \"inline_keyboard\": []\n }\n}")
val request = Request.Builder()
.url("{{baseUrl}}/editMessageCaption")
.post(body)
.addHeader("content-type", "application/json")
.build()
val response = client.newCall(request).execute()
const http = require('https');
const options = {
method: 'POST',
hostname: 'example.com',
port: null,
path: '/baseUrl/editMessageCaption',
headers: {
'content-type': 'application/json'
}
};
const req = http.request(options, function (res) {
const chunks = [];
res.on('data', function (chunk) {
chunks.push(chunk);
});
res.on('end', function () {
const body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.write(JSON.stringify({
caption: '',
caption_entities: [
{
language: '',
length: 0,
offset: 0,
type: '',
url: '',
user: {
can_join_groups: false,
can_read_all_group_messages: false,
first_name: '',
id: 0,
is_bot: false,
language_code: '',
last_name: '',
supports_inline_queries: false,
username: ''
}
}
],
chat_id: '',
inline_message_id: '',
message_id: 0,
parse_mode: '',
reply_markup: {inline_keyboard: []}
}));
req.end();
const request = require('request');
const options = {
method: 'POST',
url: '{{baseUrl}}/editMessageCaption',
headers: {'content-type': 'application/json'},
body: {
caption: '',
caption_entities: [
{
language: '',
length: 0,
offset: 0,
type: '',
url: '',
user: {
can_join_groups: false,
can_read_all_group_messages: false,
first_name: '',
id: 0,
is_bot: false,
language_code: '',
last_name: '',
supports_inline_queries: false,
username: ''
}
}
],
chat_id: '',
inline_message_id: '',
message_id: 0,
parse_mode: '',
reply_markup: {inline_keyboard: []}
},
json: true
};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
const unirest = require('unirest');
const req = unirest('POST', '{{baseUrl}}/editMessageCaption');
req.headers({
'content-type': 'application/json'
});
req.type('json');
req.send({
caption: '',
caption_entities: [
{
language: '',
length: 0,
offset: 0,
type: '',
url: '',
user: {
can_join_groups: false,
can_read_all_group_messages: false,
first_name: '',
id: 0,
is_bot: false,
language_code: '',
last_name: '',
supports_inline_queries: false,
username: ''
}
}
],
chat_id: '',
inline_message_id: '',
message_id: 0,
parse_mode: '',
reply_markup: {
inline_keyboard: []
}
});
req.end(function (res) {
if (res.error) throw new Error(res.error);
console.log(res.body);
});
const axios = require('axios').default;
const options = {
method: 'POST',
url: '{{baseUrl}}/editMessageCaption',
headers: {'content-type': 'application/json'},
data: {
caption: '',
caption_entities: [
{
language: '',
length: 0,
offset: 0,
type: '',
url: '',
user: {
can_join_groups: false,
can_read_all_group_messages: false,
first_name: '',
id: 0,
is_bot: false,
language_code: '',
last_name: '',
supports_inline_queries: false,
username: ''
}
}
],
chat_id: '',
inline_message_id: '',
message_id: 0,
parse_mode: '',
reply_markup: {inline_keyboard: []}
}
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const fetch = require('node-fetch');
const url = '{{baseUrl}}/editMessageCaption';
const options = {
method: 'POST',
headers: {'content-type': 'application/json'},
body: '{"caption":"","caption_entities":[{"language":"","length":0,"offset":0,"type":"","url":"","user":{"can_join_groups":false,"can_read_all_group_messages":false,"first_name":"","id":0,"is_bot":false,"language_code":"","last_name":"","supports_inline_queries":false,"username":""}}],"chat_id":"","inline_message_id":"","message_id":0,"parse_mode":"","reply_markup":{"inline_keyboard":[]}}'
};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
#import
NSDictionary *headers = @{ @"content-type": @"application/json" };
NSDictionary *parameters = @{ @"caption": @"",
@"caption_entities": @[ @{ @"language": @"", @"length": @0, @"offset": @0, @"type": @"", @"url": @"", @"user": @{ @"can_join_groups": @NO, @"can_read_all_group_messages": @NO, @"first_name": @"", @"id": @0, @"is_bot": @NO, @"language_code": @"", @"last_name": @"", @"supports_inline_queries": @NO, @"username": @"" } } ],
@"chat_id": @"",
@"inline_message_id": @"",
@"message_id": @0,
@"parse_mode": @"",
@"reply_markup": @{ @"inline_keyboard": @[ ] } };
NSData *postData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"{{baseUrl}}/editMessageCaption"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
[request setHTTPMethod:@"POST"];
[request setAllHTTPHeaderFields:headers];
[request setHTTPBody:postData];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSLog(@"%@", httpResponse);
}
}];
[dataTask resume];
open Cohttp_lwt_unix
open Cohttp
open Lwt
let uri = Uri.of_string "{{baseUrl}}/editMessageCaption" in
let headers = Header.add (Header.init ()) "content-type" "application/json" in
let body = Cohttp_lwt_body.of_string "{\n \"caption\": \"\",\n \"caption_entities\": [\n {\n \"language\": \"\",\n \"length\": 0,\n \"offset\": 0,\n \"type\": \"\",\n \"url\": \"\",\n \"user\": {\n \"can_join_groups\": false,\n \"can_read_all_group_messages\": false,\n \"first_name\": \"\",\n \"id\": 0,\n \"is_bot\": false,\n \"language_code\": \"\",\n \"last_name\": \"\",\n \"supports_inline_queries\": false,\n \"username\": \"\"\n }\n }\n ],\n \"chat_id\": \"\",\n \"inline_message_id\": \"\",\n \"message_id\": 0,\n \"parse_mode\": \"\",\n \"reply_markup\": {\n \"inline_keyboard\": []\n }\n}" in
Client.call ~headers ~body `POST uri
>>= fun (res, body_stream) ->
(* Do stuff with the result *)
"{{baseUrl}}/editMessageCaption",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'caption' => '',
'caption_entities' => [
[
'language' => '',
'length' => 0,
'offset' => 0,
'type' => '',
'url' => '',
'user' => [
'can_join_groups' => null,
'can_read_all_group_messages' => null,
'first_name' => '',
'id' => 0,
'is_bot' => null,
'language_code' => '',
'last_name' => '',
'supports_inline_queries' => null,
'username' => ''
]
]
],
'chat_id' => '',
'inline_message_id' => '',
'message_id' => 0,
'parse_mode' => '',
'reply_markup' => [
'inline_keyboard' => [
]
]
]),
CURLOPT_HTTPHEADER => [
"content-type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
request('POST', '{{baseUrl}}/editMessageCaption', [
'body' => '{
"caption": "",
"caption_entities": [
{
"language": "",
"length": 0,
"offset": 0,
"type": "",
"url": "",
"user": {
"can_join_groups": false,
"can_read_all_group_messages": false,
"first_name": "",
"id": 0,
"is_bot": false,
"language_code": "",
"last_name": "",
"supports_inline_queries": false,
"username": ""
}
}
],
"chat_id": "",
"inline_message_id": "",
"message_id": 0,
"parse_mode": "",
"reply_markup": {
"inline_keyboard": []
}
}',
'headers' => [
'content-type' => 'application/json',
],
]);
echo $response->getBody();
setUrl('{{baseUrl}}/editMessageCaption');
$request->setMethod(HTTP_METH_POST);
$request->setHeaders([
'content-type' => 'application/json'
]);
$request->setContentType('application/json');
$request->setBody(json_encode([
'caption' => '',
'caption_entities' => [
[
'language' => '',
'length' => 0,
'offset' => 0,
'type' => '',
'url' => '',
'user' => [
'can_join_groups' => null,
'can_read_all_group_messages' => null,
'first_name' => '',
'id' => 0,
'is_bot' => null,
'language_code' => '',
'last_name' => '',
'supports_inline_queries' => null,
'username' => ''
]
]
],
'chat_id' => '',
'inline_message_id' => '',
'message_id' => 0,
'parse_mode' => '',
'reply_markup' => [
'inline_keyboard' => [
]
]
]));
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
append(json_encode([
'caption' => '',
'caption_entities' => [
[
'language' => '',
'length' => 0,
'offset' => 0,
'type' => '',
'url' => '',
'user' => [
'can_join_groups' => null,
'can_read_all_group_messages' => null,
'first_name' => '',
'id' => 0,
'is_bot' => null,
'language_code' => '',
'last_name' => '',
'supports_inline_queries' => null,
'username' => ''
]
]
],
'chat_id' => '',
'inline_message_id' => '',
'message_id' => 0,
'parse_mode' => '',
'reply_markup' => [
'inline_keyboard' => [
]
]
]));
$request->setRequestUrl('{{baseUrl}}/editMessageCaption');
$request->setRequestMethod('POST');
$request->setBody($body);
$request->setHeaders([
'content-type' => 'application/json'
]);
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
$headers=@{}
$headers.Add("content-type", "application/json")
$response = Invoke-WebRequest -Uri '{{baseUrl}}/editMessageCaption' -Method POST -Headers $headers -ContentType 'application/json' -Body '{
"caption": "",
"caption_entities": [
{
"language": "",
"length": 0,
"offset": 0,
"type": "",
"url": "",
"user": {
"can_join_groups": false,
"can_read_all_group_messages": false,
"first_name": "",
"id": 0,
"is_bot": false,
"language_code": "",
"last_name": "",
"supports_inline_queries": false,
"username": ""
}
}
],
"chat_id": "",
"inline_message_id": "",
"message_id": 0,
"parse_mode": "",
"reply_markup": {
"inline_keyboard": []
}
}'
$headers=@{}
$headers.Add("content-type", "application/json")
$response = Invoke-RestMethod -Uri '{{baseUrl}}/editMessageCaption' -Method POST -Headers $headers -ContentType 'application/json' -Body '{
"caption": "",
"caption_entities": [
{
"language": "",
"length": 0,
"offset": 0,
"type": "",
"url": "",
"user": {
"can_join_groups": false,
"can_read_all_group_messages": false,
"first_name": "",
"id": 0,
"is_bot": false,
"language_code": "",
"last_name": "",
"supports_inline_queries": false,
"username": ""
}
}
],
"chat_id": "",
"inline_message_id": "",
"message_id": 0,
"parse_mode": "",
"reply_markup": {
"inline_keyboard": []
}
}'
import http.client
conn = http.client.HTTPSConnection("example.com")
payload = "{\n \"caption\": \"\",\n \"caption_entities\": [\n {\n \"language\": \"\",\n \"length\": 0,\n \"offset\": 0,\n \"type\": \"\",\n \"url\": \"\",\n \"user\": {\n \"can_join_groups\": false,\n \"can_read_all_group_messages\": false,\n \"first_name\": \"\",\n \"id\": 0,\n \"is_bot\": false,\n \"language_code\": \"\",\n \"last_name\": \"\",\n \"supports_inline_queries\": false,\n \"username\": \"\"\n }\n }\n ],\n \"chat_id\": \"\",\n \"inline_message_id\": \"\",\n \"message_id\": 0,\n \"parse_mode\": \"\",\n \"reply_markup\": {\n \"inline_keyboard\": []\n }\n}"
headers = { 'content-type': "application/json" }
conn.request("POST", "/baseUrl/editMessageCaption", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
import requests
url = "{{baseUrl}}/editMessageCaption"
payload = {
"caption": "",
"caption_entities": [
{
"language": "",
"length": 0,
"offset": 0,
"type": "",
"url": "",
"user": {
"can_join_groups": False,
"can_read_all_group_messages": False,
"first_name": "",
"id": 0,
"is_bot": False,
"language_code": "",
"last_name": "",
"supports_inline_queries": False,
"username": ""
}
}
],
"chat_id": "",
"inline_message_id": "",
"message_id": 0,
"parse_mode": "",
"reply_markup": { "inline_keyboard": [] }
}
headers = {"content-type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
library(httr)
url <- "{{baseUrl}}/editMessageCaption"
payload <- "{\n \"caption\": \"\",\n \"caption_entities\": [\n {\n \"language\": \"\",\n \"length\": 0,\n \"offset\": 0,\n \"type\": \"\",\n \"url\": \"\",\n \"user\": {\n \"can_join_groups\": false,\n \"can_read_all_group_messages\": false,\n \"first_name\": \"\",\n \"id\": 0,\n \"is_bot\": false,\n \"language_code\": \"\",\n \"last_name\": \"\",\n \"supports_inline_queries\": false,\n \"username\": \"\"\n }\n }\n ],\n \"chat_id\": \"\",\n \"inline_message_id\": \"\",\n \"message_id\": 0,\n \"parse_mode\": \"\",\n \"reply_markup\": {\n \"inline_keyboard\": []\n }\n}"
encode <- "json"
response <- VERB("POST", url, body = payload, content_type("application/json"), encode = encode)
content(response, "text")
require 'uri'
require 'net/http'
url = URI("{{baseUrl}}/editMessageCaption")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["content-type"] = 'application/json'
request.body = "{\n \"caption\": \"\",\n \"caption_entities\": [\n {\n \"language\": \"\",\n \"length\": 0,\n \"offset\": 0,\n \"type\": \"\",\n \"url\": \"\",\n \"user\": {\n \"can_join_groups\": false,\n \"can_read_all_group_messages\": false,\n \"first_name\": \"\",\n \"id\": 0,\n \"is_bot\": false,\n \"language_code\": \"\",\n \"last_name\": \"\",\n \"supports_inline_queries\": false,\n \"username\": \"\"\n }\n }\n ],\n \"chat_id\": \"\",\n \"inline_message_id\": \"\",\n \"message_id\": 0,\n \"parse_mode\": \"\",\n \"reply_markup\": {\n \"inline_keyboard\": []\n }\n}"
response = http.request(request)
puts response.read_body
require 'faraday'
conn = Faraday.new(
url: 'https://example.com',
headers: {'Content-Type' => 'application/json'}
)
response = conn.post('/baseUrl/editMessageCaption') do |req|
req.body = "{\n \"caption\": \"\",\n \"caption_entities\": [\n {\n \"language\": \"\",\n \"length\": 0,\n \"offset\": 0,\n \"type\": \"\",\n \"url\": \"\",\n \"user\": {\n \"can_join_groups\": false,\n \"can_read_all_group_messages\": false,\n \"first_name\": \"\",\n \"id\": 0,\n \"is_bot\": false,\n \"language_code\": \"\",\n \"last_name\": \"\",\n \"supports_inline_queries\": false,\n \"username\": \"\"\n }\n }\n ],\n \"chat_id\": \"\",\n \"inline_message_id\": \"\",\n \"message_id\": 0,\n \"parse_mode\": \"\",\n \"reply_markup\": {\n \"inline_keyboard\": []\n }\n}"
end
puts response.status
puts response.body
use serde_json::json;
use reqwest;
#[tokio::main]
pub async fn main() {
let url = "{{baseUrl}}/editMessageCaption";
let payload = json!({
"caption": "",
"caption_entities": (
json!({
"language": "",
"length": 0,
"offset": 0,
"type": "",
"url": "",
"user": json!({
"can_join_groups": false,
"can_read_all_group_messages": false,
"first_name": "",
"id": 0,
"is_bot": false,
"language_code": "",
"last_name": "",
"supports_inline_queries": false,
"username": ""
})
})
),
"chat_id": "",
"inline_message_id": "",
"message_id": 0,
"parse_mode": "",
"reply_markup": json!({"inline_keyboard": ()})
});
let mut headers = reqwest::header::HeaderMap::new();
headers.insert("content-type", "application/json".parse().unwrap());
let client = reqwest::Client::new();
let response = client.post(url)
.headers(headers)
.json(&payload)
.send()
.await;
let results = response.unwrap()
.json::()
.await
.unwrap();
dbg!(results);
}
curl --request POST \
--url {{baseUrl}}/editMessageCaption \
--header 'content-type: application/json' \
--data '{
"caption": "",
"caption_entities": [
{
"language": "",
"length": 0,
"offset": 0,
"type": "",
"url": "",
"user": {
"can_join_groups": false,
"can_read_all_group_messages": false,
"first_name": "",
"id": 0,
"is_bot": false,
"language_code": "",
"last_name": "",
"supports_inline_queries": false,
"username": ""
}
}
],
"chat_id": "",
"inline_message_id": "",
"message_id": 0,
"parse_mode": "",
"reply_markup": {
"inline_keyboard": []
}
}'
echo '{
"caption": "",
"caption_entities": [
{
"language": "",
"length": 0,
"offset": 0,
"type": "",
"url": "",
"user": {
"can_join_groups": false,
"can_read_all_group_messages": false,
"first_name": "",
"id": 0,
"is_bot": false,
"language_code": "",
"last_name": "",
"supports_inline_queries": false,
"username": ""
}
}
],
"chat_id": "",
"inline_message_id": "",
"message_id": 0,
"parse_mode": "",
"reply_markup": {
"inline_keyboard": []
}
}' | \
http POST {{baseUrl}}/editMessageCaption \
content-type:application/json
wget --quiet \
--method POST \
--header 'content-type: application/json' \
--body-data '{\n "caption": "",\n "caption_entities": [\n {\n "language": "",\n "length": 0,\n "offset": 0,\n "type": "",\n "url": "",\n "user": {\n "can_join_groups": false,\n "can_read_all_group_messages": false,\n "first_name": "",\n "id": 0,\n "is_bot": false,\n "language_code": "",\n "last_name": "",\n "supports_inline_queries": false,\n "username": ""\n }\n }\n ],\n "chat_id": "",\n "inline_message_id": "",\n "message_id": 0,\n "parse_mode": "",\n "reply_markup": {\n "inline_keyboard": []\n }\n}' \
--output-document \
- {{baseUrl}}/editMessageCaption
import Foundation
let headers = ["content-type": "application/json"]
let parameters = [
"caption": "",
"caption_entities": [
[
"language": "",
"length": 0,
"offset": 0,
"type": "",
"url": "",
"user": [
"can_join_groups": false,
"can_read_all_group_messages": false,
"first_name": "",
"id": 0,
"is_bot": false,
"language_code": "",
"last_name": "",
"supports_inline_queries": false,
"username": ""
]
]
],
"chat_id": "",
"inline_message_id": "",
"message_id": 0,
"parse_mode": "",
"reply_markup": ["inline_keyboard": []]
] as [String : Any]
let postData = JSONSerialization.data(withJSONObject: parameters, options: [])
let request = NSMutableURLRequest(url: NSURL(string: "{{baseUrl}}/editMessageCaption")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error as Any)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
POST
Use this method to edit only the reply markup of messages. On success, if the edited message is not an inline message, the edited [Message](https---core.telegram.org-bots-api-#message) is returned, otherwise -True- is returned.
{{baseUrl}}/editMessageReplyMarkup
BODY json
{
"chat_id": "",
"inline_message_id": "",
"message_id": 0,
"reply_markup": {
"inline_keyboard": []
}
}
Examples
REQUEST
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(hnd, CURLOPT_URL, "{{baseUrl}}/editMessageReplyMarkup");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "content-type: application/json");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "{\n \"chat_id\": \"\",\n \"inline_message_id\": \"\",\n \"message_id\": 0,\n \"reply_markup\": {\n \"inline_keyboard\": []\n }\n}");
CURLcode ret = curl_easy_perform(hnd);
(require '[clj-http.client :as client])
(client/post "{{baseUrl}}/editMessageReplyMarkup" {:content-type :json
:form-params {:chat_id ""
:inline_message_id ""
:message_id 0
:reply_markup {:inline_keyboard []}}})
require "http/client"
url = "{{baseUrl}}/editMessageReplyMarkup"
headers = HTTP::Headers{
"content-type" => "application/json"
}
reqBody = "{\n \"chat_id\": \"\",\n \"inline_message_id\": \"\",\n \"message_id\": 0,\n \"reply_markup\": {\n \"inline_keyboard\": []\n }\n}"
response = HTTP::Client.post url, headers: headers, body: reqBody
puts response.body
using System.Net.Http.Headers;
var client = new HttpClient();
var request = new HttpRequestMessage
{
Method = HttpMethod.Post,
RequestUri = new Uri("{{baseUrl}}/editMessageReplyMarkup"),
Content = new StringContent("{\n \"chat_id\": \"\",\n \"inline_message_id\": \"\",\n \"message_id\": 0,\n \"reply_markup\": {\n \"inline_keyboard\": []\n }\n}")
{
Headers =
{
ContentType = new MediaTypeHeaderValue("application/json")
}
}
};
using (var response = await client.SendAsync(request))
{
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
}
var client = new RestClient("{{baseUrl}}/editMessageReplyMarkup");
var request = new RestRequest("", Method.Post);
request.AddHeader("content-type", "application/json");
request.AddParameter("application/json", "{\n \"chat_id\": \"\",\n \"inline_message_id\": \"\",\n \"message_id\": 0,\n \"reply_markup\": {\n \"inline_keyboard\": []\n }\n}", ParameterType.RequestBody);
var response = client.Execute(request);
package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "{{baseUrl}}/editMessageReplyMarkup"
payload := strings.NewReader("{\n \"chat_id\": \"\",\n \"inline_message_id\": \"\",\n \"message_id\": 0,\n \"reply_markup\": {\n \"inline_keyboard\": []\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("content-type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
POST /baseUrl/editMessageReplyMarkup HTTP/1.1
Content-Type: application/json
Host: example.com
Content-Length: 116
{
"chat_id": "",
"inline_message_id": "",
"message_id": 0,
"reply_markup": {
"inline_keyboard": []
}
}
AsyncHttpClient client = new DefaultAsyncHttpClient();
client.prepare("POST", "{{baseUrl}}/editMessageReplyMarkup")
.setHeader("content-type", "application/json")
.setBody("{\n \"chat_id\": \"\",\n \"inline_message_id\": \"\",\n \"message_id\": 0,\n \"reply_markup\": {\n \"inline_keyboard\": []\n }\n}")
.execute()
.toCompletableFuture()
.thenAccept(System.out::println)
.join();
client.close();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("{{baseUrl}}/editMessageReplyMarkup"))
.header("content-type", "application/json")
.method("POST", HttpRequest.BodyPublishers.ofString("{\n \"chat_id\": \"\",\n \"inline_message_id\": \"\",\n \"message_id\": 0,\n \"reply_markup\": {\n \"inline_keyboard\": []\n }\n}"))
.build();
HttpResponse response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n \"chat_id\": \"\",\n \"inline_message_id\": \"\",\n \"message_id\": 0,\n \"reply_markup\": {\n \"inline_keyboard\": []\n }\n}");
Request request = new Request.Builder()
.url("{{baseUrl}}/editMessageReplyMarkup")
.post(body)
.addHeader("content-type", "application/json")
.build();
Response response = client.newCall(request).execute();
HttpResponse response = Unirest.post("{{baseUrl}}/editMessageReplyMarkup")
.header("content-type", "application/json")
.body("{\n \"chat_id\": \"\",\n \"inline_message_id\": \"\",\n \"message_id\": 0,\n \"reply_markup\": {\n \"inline_keyboard\": []\n }\n}")
.asString();
const data = JSON.stringify({
chat_id: '',
inline_message_id: '',
message_id: 0,
reply_markup: {
inline_keyboard: []
}
});
const xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener('readystatechange', function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open('POST', '{{baseUrl}}/editMessageReplyMarkup');
xhr.setRequestHeader('content-type', 'application/json');
xhr.send(data);
import axios from 'axios';
const options = {
method: 'POST',
url: '{{baseUrl}}/editMessageReplyMarkup',
headers: {'content-type': 'application/json'},
data: {
chat_id: '',
inline_message_id: '',
message_id: 0,
reply_markup: {inline_keyboard: []}
}
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const url = '{{baseUrl}}/editMessageReplyMarkup';
const options = {
method: 'POST',
headers: {'content-type': 'application/json'},
body: '{"chat_id":"","inline_message_id":"","message_id":0,"reply_markup":{"inline_keyboard":[]}}'
};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
const settings = {
async: true,
crossDomain: true,
url: '{{baseUrl}}/editMessageReplyMarkup',
method: 'POST',
headers: {
'content-type': 'application/json'
},
processData: false,
data: '{\n "chat_id": "",\n "inline_message_id": "",\n "message_id": 0,\n "reply_markup": {\n "inline_keyboard": []\n }\n}'
};
$.ajax(settings).done(function (response) {
console.log(response);
});
val client = OkHttpClient()
val mediaType = MediaType.parse("application/json")
val body = RequestBody.create(mediaType, "{\n \"chat_id\": \"\",\n \"inline_message_id\": \"\",\n \"message_id\": 0,\n \"reply_markup\": {\n \"inline_keyboard\": []\n }\n}")
val request = Request.Builder()
.url("{{baseUrl}}/editMessageReplyMarkup")
.post(body)
.addHeader("content-type", "application/json")
.build()
val response = client.newCall(request).execute()
const http = require('https');
const options = {
method: 'POST',
hostname: 'example.com',
port: null,
path: '/baseUrl/editMessageReplyMarkup',
headers: {
'content-type': 'application/json'
}
};
const req = http.request(options, function (res) {
const chunks = [];
res.on('data', function (chunk) {
chunks.push(chunk);
});
res.on('end', function () {
const body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.write(JSON.stringify({
chat_id: '',
inline_message_id: '',
message_id: 0,
reply_markup: {inline_keyboard: []}
}));
req.end();
const request = require('request');
const options = {
method: 'POST',
url: '{{baseUrl}}/editMessageReplyMarkup',
headers: {'content-type': 'application/json'},
body: {
chat_id: '',
inline_message_id: '',
message_id: 0,
reply_markup: {inline_keyboard: []}
},
json: true
};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
const unirest = require('unirest');
const req = unirest('POST', '{{baseUrl}}/editMessageReplyMarkup');
req.headers({
'content-type': 'application/json'
});
req.type('json');
req.send({
chat_id: '',
inline_message_id: '',
message_id: 0,
reply_markup: {
inline_keyboard: []
}
});
req.end(function (res) {
if (res.error) throw new Error(res.error);
console.log(res.body);
});
const axios = require('axios').default;
const options = {
method: 'POST',
url: '{{baseUrl}}/editMessageReplyMarkup',
headers: {'content-type': 'application/json'},
data: {
chat_id: '',
inline_message_id: '',
message_id: 0,
reply_markup: {inline_keyboard: []}
}
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const fetch = require('node-fetch');
const url = '{{baseUrl}}/editMessageReplyMarkup';
const options = {
method: 'POST',
headers: {'content-type': 'application/json'},
body: '{"chat_id":"","inline_message_id":"","message_id":0,"reply_markup":{"inline_keyboard":[]}}'
};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
#import
NSDictionary *headers = @{ @"content-type": @"application/json" };
NSDictionary *parameters = @{ @"chat_id": @"",
@"inline_message_id": @"",
@"message_id": @0,
@"reply_markup": @{ @"inline_keyboard": @[ ] } };
NSData *postData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"{{baseUrl}}/editMessageReplyMarkup"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
[request setHTTPMethod:@"POST"];
[request setAllHTTPHeaderFields:headers];
[request setHTTPBody:postData];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSLog(@"%@", httpResponse);
}
}];
[dataTask resume];
open Cohttp_lwt_unix
open Cohttp
open Lwt
let uri = Uri.of_string "{{baseUrl}}/editMessageReplyMarkup" in
let headers = Header.add (Header.init ()) "content-type" "application/json" in
let body = Cohttp_lwt_body.of_string "{\n \"chat_id\": \"\",\n \"inline_message_id\": \"\",\n \"message_id\": 0,\n \"reply_markup\": {\n \"inline_keyboard\": []\n }\n}" in
Client.call ~headers ~body `POST uri
>>= fun (res, body_stream) ->
(* Do stuff with the result *)
"{{baseUrl}}/editMessageReplyMarkup",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'chat_id' => '',
'inline_message_id' => '',
'message_id' => 0,
'reply_markup' => [
'inline_keyboard' => [
]
]
]),
CURLOPT_HTTPHEADER => [
"content-type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
request('POST', '{{baseUrl}}/editMessageReplyMarkup', [
'body' => '{
"chat_id": "",
"inline_message_id": "",
"message_id": 0,
"reply_markup": {
"inline_keyboard": []
}
}',
'headers' => [
'content-type' => 'application/json',
],
]);
echo $response->getBody();
setUrl('{{baseUrl}}/editMessageReplyMarkup');
$request->setMethod(HTTP_METH_POST);
$request->setHeaders([
'content-type' => 'application/json'
]);
$request->setContentType('application/json');
$request->setBody(json_encode([
'chat_id' => '',
'inline_message_id' => '',
'message_id' => 0,
'reply_markup' => [
'inline_keyboard' => [
]
]
]));
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
append(json_encode([
'chat_id' => '',
'inline_message_id' => '',
'message_id' => 0,
'reply_markup' => [
'inline_keyboard' => [
]
]
]));
$request->setRequestUrl('{{baseUrl}}/editMessageReplyMarkup');
$request->setRequestMethod('POST');
$request->setBody($body);
$request->setHeaders([
'content-type' => 'application/json'
]);
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
$headers=@{}
$headers.Add("content-type", "application/json")
$response = Invoke-WebRequest -Uri '{{baseUrl}}/editMessageReplyMarkup' -Method POST -Headers $headers -ContentType 'application/json' -Body '{
"chat_id": "",
"inline_message_id": "",
"message_id": 0,
"reply_markup": {
"inline_keyboard": []
}
}'
$headers=@{}
$headers.Add("content-type", "application/json")
$response = Invoke-RestMethod -Uri '{{baseUrl}}/editMessageReplyMarkup' -Method POST -Headers $headers -ContentType 'application/json' -Body '{
"chat_id": "",
"inline_message_id": "",
"message_id": 0,
"reply_markup": {
"inline_keyboard": []
}
}'
import http.client
conn = http.client.HTTPSConnection("example.com")
payload = "{\n \"chat_id\": \"\",\n \"inline_message_id\": \"\",\n \"message_id\": 0,\n \"reply_markup\": {\n \"inline_keyboard\": []\n }\n}"
headers = { 'content-type': "application/json" }
conn.request("POST", "/baseUrl/editMessageReplyMarkup", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
import requests
url = "{{baseUrl}}/editMessageReplyMarkup"
payload = {
"chat_id": "",
"inline_message_id": "",
"message_id": 0,
"reply_markup": { "inline_keyboard": [] }
}
headers = {"content-type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
library(httr)
url <- "{{baseUrl}}/editMessageReplyMarkup"
payload <- "{\n \"chat_id\": \"\",\n \"inline_message_id\": \"\",\n \"message_id\": 0,\n \"reply_markup\": {\n \"inline_keyboard\": []\n }\n}"
encode <- "json"
response <- VERB("POST", url, body = payload, content_type("application/json"), encode = encode)
content(response, "text")
require 'uri'
require 'net/http'
url = URI("{{baseUrl}}/editMessageReplyMarkup")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["content-type"] = 'application/json'
request.body = "{\n \"chat_id\": \"\",\n \"inline_message_id\": \"\",\n \"message_id\": 0,\n \"reply_markup\": {\n \"inline_keyboard\": []\n }\n}"
response = http.request(request)
puts response.read_body
require 'faraday'
conn = Faraday.new(
url: 'https://example.com',
headers: {'Content-Type' => 'application/json'}
)
response = conn.post('/baseUrl/editMessageReplyMarkup') do |req|
req.body = "{\n \"chat_id\": \"\",\n \"inline_message_id\": \"\",\n \"message_id\": 0,\n \"reply_markup\": {\n \"inline_keyboard\": []\n }\n}"
end
puts response.status
puts response.body
use serde_json::json;
use reqwest;
#[tokio::main]
pub async fn main() {
let url = "{{baseUrl}}/editMessageReplyMarkup";
let payload = json!({
"chat_id": "",
"inline_message_id": "",
"message_id": 0,
"reply_markup": json!({"inline_keyboard": ()})
});
let mut headers = reqwest::header::HeaderMap::new();
headers.insert("content-type", "application/json".parse().unwrap());
let client = reqwest::Client::new();
let response = client.post(url)
.headers(headers)
.json(&payload)
.send()
.await;
let results = response.unwrap()
.json::()
.await
.unwrap();
dbg!(results);
}
curl --request POST \
--url {{baseUrl}}/editMessageReplyMarkup \
--header 'content-type: application/json' \
--data '{
"chat_id": "",
"inline_message_id": "",
"message_id": 0,
"reply_markup": {
"inline_keyboard": []
}
}'
echo '{
"chat_id": "",
"inline_message_id": "",
"message_id": 0,
"reply_markup": {
"inline_keyboard": []
}
}' | \
http POST {{baseUrl}}/editMessageReplyMarkup \
content-type:application/json
wget --quiet \
--method POST \
--header 'content-type: application/json' \
--body-data '{\n "chat_id": "",\n "inline_message_id": "",\n "message_id": 0,\n "reply_markup": {\n "inline_keyboard": []\n }\n}' \
--output-document \
- {{baseUrl}}/editMessageReplyMarkup
import Foundation
let headers = ["content-type": "application/json"]
let parameters = [
"chat_id": "",
"inline_message_id": "",
"message_id": 0,
"reply_markup": ["inline_keyboard": []]
] as [String : Any]
let postData = JSONSerialization.data(withJSONObject: parameters, options: [])
let request = NSMutableURLRequest(url: NSURL(string: "{{baseUrl}}/editMessageReplyMarkup")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error as Any)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
POST
Use this method to forward messages of any kind. On success, the sent [Message](https---core.telegram.org-bots-api-#message) is returned.
{{baseUrl}}/forwardMessage
BODY json
{
"chat_id": "",
"disable_notification": false,
"from_chat_id": "",
"message_id": 0
}
Examples
REQUEST
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(hnd, CURLOPT_URL, "{{baseUrl}}/forwardMessage");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "content-type: application/json");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "{\n \"chat_id\": \"\",\n \"disable_notification\": false,\n \"from_chat_id\": \"\",\n \"message_id\": 0\n}");
CURLcode ret = curl_easy_perform(hnd);
(require '[clj-http.client :as client])
(client/post "{{baseUrl}}/forwardMessage" {:content-type :json
:form-params {:chat_id ""
:disable_notification false
:from_chat_id ""
:message_id 0}})
require "http/client"
url = "{{baseUrl}}/forwardMessage"
headers = HTTP::Headers{
"content-type" => "application/json"
}
reqBody = "{\n \"chat_id\": \"\",\n \"disable_notification\": false,\n \"from_chat_id\": \"\",\n \"message_id\": 0\n}"
response = HTTP::Client.post url, headers: headers, body: reqBody
puts response.body
using System.Net.Http.Headers;
var client = new HttpClient();
var request = new HttpRequestMessage
{
Method = HttpMethod.Post,
RequestUri = new Uri("{{baseUrl}}/forwardMessage"),
Content = new StringContent("{\n \"chat_id\": \"\",\n \"disable_notification\": false,\n \"from_chat_id\": \"\",\n \"message_id\": 0\n}")
{
Headers =
{
ContentType = new MediaTypeHeaderValue("application/json")
}
}
};
using (var response = await client.SendAsync(request))
{
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
}
var client = new RestClient("{{baseUrl}}/forwardMessage");
var request = new RestRequest("", Method.Post);
request.AddHeader("content-type", "application/json");
request.AddParameter("application/json", "{\n \"chat_id\": \"\",\n \"disable_notification\": false,\n \"from_chat_id\": \"\",\n \"message_id\": 0\n}", ParameterType.RequestBody);
var response = client.Execute(request);
package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "{{baseUrl}}/forwardMessage"
payload := strings.NewReader("{\n \"chat_id\": \"\",\n \"disable_notification\": false,\n \"from_chat_id\": \"\",\n \"message_id\": 0\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("content-type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
POST /baseUrl/forwardMessage HTTP/1.1
Content-Type: application/json
Host: example.com
Content-Length: 93
{
"chat_id": "",
"disable_notification": false,
"from_chat_id": "",
"message_id": 0
}
AsyncHttpClient client = new DefaultAsyncHttpClient();
client.prepare("POST", "{{baseUrl}}/forwardMessage")
.setHeader("content-type", "application/json")
.setBody("{\n \"chat_id\": \"\",\n \"disable_notification\": false,\n \"from_chat_id\": \"\",\n \"message_id\": 0\n}")
.execute()
.toCompletableFuture()
.thenAccept(System.out::println)
.join();
client.close();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("{{baseUrl}}/forwardMessage"))
.header("content-type", "application/json")
.method("POST", HttpRequest.BodyPublishers.ofString("{\n \"chat_id\": \"\",\n \"disable_notification\": false,\n \"from_chat_id\": \"\",\n \"message_id\": 0\n}"))
.build();
HttpResponse response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n \"chat_id\": \"\",\n \"disable_notification\": false,\n \"from_chat_id\": \"\",\n \"message_id\": 0\n}");
Request request = new Request.Builder()
.url("{{baseUrl}}/forwardMessage")
.post(body)
.addHeader("content-type", "application/json")
.build();
Response response = client.newCall(request).execute();
HttpResponse response = Unirest.post("{{baseUrl}}/forwardMessage")
.header("content-type", "application/json")
.body("{\n \"chat_id\": \"\",\n \"disable_notification\": false,\n \"from_chat_id\": \"\",\n \"message_id\": 0\n}")
.asString();
const data = JSON.stringify({
chat_id: '',
disable_notification: false,
from_chat_id: '',
message_id: 0
});
const xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener('readystatechange', function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open('POST', '{{baseUrl}}/forwardMessage');
xhr.setRequestHeader('content-type', 'application/json');
xhr.send(data);
import axios from 'axios';
const options = {
method: 'POST',
url: '{{baseUrl}}/forwardMessage',
headers: {'content-type': 'application/json'},
data: {chat_id: '', disable_notification: false, from_chat_id: '', message_id: 0}
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const url = '{{baseUrl}}/forwardMessage';
const options = {
method: 'POST',
headers: {'content-type': 'application/json'},
body: '{"chat_id":"","disable_notification":false,"from_chat_id":"","message_id":0}'
};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
const settings = {
async: true,
crossDomain: true,
url: '{{baseUrl}}/forwardMessage',
method: 'POST',
headers: {
'content-type': 'application/json'
},
processData: false,
data: '{\n "chat_id": "",\n "disable_notification": false,\n "from_chat_id": "",\n "message_id": 0\n}'
};
$.ajax(settings).done(function (response) {
console.log(response);
});
val client = OkHttpClient()
val mediaType = MediaType.parse("application/json")
val body = RequestBody.create(mediaType, "{\n \"chat_id\": \"\",\n \"disable_notification\": false,\n \"from_chat_id\": \"\",\n \"message_id\": 0\n}")
val request = Request.Builder()
.url("{{baseUrl}}/forwardMessage")
.post(body)
.addHeader("content-type", "application/json")
.build()
val response = client.newCall(request).execute()
const http = require('https');
const options = {
method: 'POST',
hostname: 'example.com',
port: null,
path: '/baseUrl/forwardMessage',
headers: {
'content-type': 'application/json'
}
};
const req = http.request(options, function (res) {
const chunks = [];
res.on('data', function (chunk) {
chunks.push(chunk);
});
res.on('end', function () {
const body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.write(JSON.stringify({chat_id: '', disable_notification: false, from_chat_id: '', message_id: 0}));
req.end();
const request = require('request');
const options = {
method: 'POST',
url: '{{baseUrl}}/forwardMessage',
headers: {'content-type': 'application/json'},
body: {chat_id: '', disable_notification: false, from_chat_id: '', message_id: 0},
json: true
};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
const unirest = require('unirest');
const req = unirest('POST', '{{baseUrl}}/forwardMessage');
req.headers({
'content-type': 'application/json'
});
req.type('json');
req.send({
chat_id: '',
disable_notification: false,
from_chat_id: '',
message_id: 0
});
req.end(function (res) {
if (res.error) throw new Error(res.error);
console.log(res.body);
});
const axios = require('axios').default;
const options = {
method: 'POST',
url: '{{baseUrl}}/forwardMessage',
headers: {'content-type': 'application/json'},
data: {chat_id: '', disable_notification: false, from_chat_id: '', message_id: 0}
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const fetch = require('node-fetch');
const url = '{{baseUrl}}/forwardMessage';
const options = {
method: 'POST',
headers: {'content-type': 'application/json'},
body: '{"chat_id":"","disable_notification":false,"from_chat_id":"","message_id":0}'
};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
#import
NSDictionary *headers = @{ @"content-type": @"application/json" };
NSDictionary *parameters = @{ @"chat_id": @"",
@"disable_notification": @NO,
@"from_chat_id": @"",
@"message_id": @0 };
NSData *postData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"{{baseUrl}}/forwardMessage"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
[request setHTTPMethod:@"POST"];
[request setAllHTTPHeaderFields:headers];
[request setHTTPBody:postData];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSLog(@"%@", httpResponse);
}
}];
[dataTask resume];
open Cohttp_lwt_unix
open Cohttp
open Lwt
let uri = Uri.of_string "{{baseUrl}}/forwardMessage" in
let headers = Header.add (Header.init ()) "content-type" "application/json" in
let body = Cohttp_lwt_body.of_string "{\n \"chat_id\": \"\",\n \"disable_notification\": false,\n \"from_chat_id\": \"\",\n \"message_id\": 0\n}" in
Client.call ~headers ~body `POST uri
>>= fun (res, body_stream) ->
(* Do stuff with the result *)
"{{baseUrl}}/forwardMessage",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'chat_id' => '',
'disable_notification' => null,
'from_chat_id' => '',
'message_id' => 0
]),
CURLOPT_HTTPHEADER => [
"content-type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
request('POST', '{{baseUrl}}/forwardMessage', [
'body' => '{
"chat_id": "",
"disable_notification": false,
"from_chat_id": "",
"message_id": 0
}',
'headers' => [
'content-type' => 'application/json',
],
]);
echo $response->getBody();
setUrl('{{baseUrl}}/forwardMessage');
$request->setMethod(HTTP_METH_POST);
$request->setHeaders([
'content-type' => 'application/json'
]);
$request->setContentType('application/json');
$request->setBody(json_encode([
'chat_id' => '',
'disable_notification' => null,
'from_chat_id' => '',
'message_id' => 0
]));
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
append(json_encode([
'chat_id' => '',
'disable_notification' => null,
'from_chat_id' => '',
'message_id' => 0
]));
$request->setRequestUrl('{{baseUrl}}/forwardMessage');
$request->setRequestMethod('POST');
$request->setBody($body);
$request->setHeaders([
'content-type' => 'application/json'
]);
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
$headers=@{}
$headers.Add("content-type", "application/json")
$response = Invoke-WebRequest -Uri '{{baseUrl}}/forwardMessage' -Method POST -Headers $headers -ContentType 'application/json' -Body '{
"chat_id": "",
"disable_notification": false,
"from_chat_id": "",
"message_id": 0
}'
$headers=@{}
$headers.Add("content-type", "application/json")
$response = Invoke-RestMethod -Uri '{{baseUrl}}/forwardMessage' -Method POST -Headers $headers -ContentType 'application/json' -Body '{
"chat_id": "",
"disable_notification": false,
"from_chat_id": "",
"message_id": 0
}'
import http.client
conn = http.client.HTTPSConnection("example.com")
payload = "{\n \"chat_id\": \"\",\n \"disable_notification\": false,\n \"from_chat_id\": \"\",\n \"message_id\": 0\n}"
headers = { 'content-type': "application/json" }
conn.request("POST", "/baseUrl/forwardMessage", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
import requests
url = "{{baseUrl}}/forwardMessage"
payload = {
"chat_id": "",
"disable_notification": False,
"from_chat_id": "",
"message_id": 0
}
headers = {"content-type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
library(httr)
url <- "{{baseUrl}}/forwardMessage"
payload <- "{\n \"chat_id\": \"\",\n \"disable_notification\": false,\n \"from_chat_id\": \"\",\n \"message_id\": 0\n}"
encode <- "json"
response <- VERB("POST", url, body = payload, content_type("application/json"), encode = encode)
content(response, "text")
require 'uri'
require 'net/http'
url = URI("{{baseUrl}}/forwardMessage")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["content-type"] = 'application/json'
request.body = "{\n \"chat_id\": \"\",\n \"disable_notification\": false,\n \"from_chat_id\": \"\",\n \"message_id\": 0\n}"
response = http.request(request)
puts response.read_body
require 'faraday'
conn = Faraday.new(
url: 'https://example.com',
headers: {'Content-Type' => 'application/json'}
)
response = conn.post('/baseUrl/forwardMessage') do |req|
req.body = "{\n \"chat_id\": \"\",\n \"disable_notification\": false,\n \"from_chat_id\": \"\",\n \"message_id\": 0\n}"
end
puts response.status
puts response.body
use serde_json::json;
use reqwest;
#[tokio::main]
pub async fn main() {
let url = "{{baseUrl}}/forwardMessage";
let payload = json!({
"chat_id": "",
"disable_notification": false,
"from_chat_id": "",
"message_id": 0
});
let mut headers = reqwest::header::HeaderMap::new();
headers.insert("content-type", "application/json".parse().unwrap());
let client = reqwest::Client::new();
let response = client.post(url)
.headers(headers)
.json(&payload)
.send()
.await;
let results = response.unwrap()
.json::()
.await
.unwrap();
dbg!(results);
}
curl --request POST \
--url {{baseUrl}}/forwardMessage \
--header 'content-type: application/json' \
--data '{
"chat_id": "",
"disable_notification": false,
"from_chat_id": "",
"message_id": 0
}'
echo '{
"chat_id": "",
"disable_notification": false,
"from_chat_id": "",
"message_id": 0
}' | \
http POST {{baseUrl}}/forwardMessage \
content-type:application/json
wget --quiet \
--method POST \
--header 'content-type: application/json' \
--body-data '{\n "chat_id": "",\n "disable_notification": false,\n "from_chat_id": "",\n "message_id": 0\n}' \
--output-document \
- {{baseUrl}}/forwardMessage
import Foundation
let headers = ["content-type": "application/json"]
let parameters = [
"chat_id": "",
"disable_notification": false,
"from_chat_id": "",
"message_id": 0
] as [String : Any]
let postData = JSONSerialization.data(withJSONObject: parameters, options: [])
let request = NSMutableURLRequest(url: NSURL(string: "{{baseUrl}}/forwardMessage")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error as Any)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
POST
Use this method to get a list of profile pictures for a user. Returns a [UserProfilePhotos](https---core.telegram.org-bots-api-#userprofilephotos) object.
{{baseUrl}}/getUserProfilePhotos
BODY json
{
"limit": 0,
"offset": 0,
"user_id": 0
}
Examples
REQUEST
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(hnd, CURLOPT_URL, "{{baseUrl}}/getUserProfilePhotos");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "content-type: application/json");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "{\n \"limit\": 0,\n \"offset\": 0,\n \"user_id\": 0\n}");
CURLcode ret = curl_easy_perform(hnd);
(require '[clj-http.client :as client])
(client/post "{{baseUrl}}/getUserProfilePhotos" {:content-type :json
:form-params {:limit 0
:offset 0
:user_id 0}})
require "http/client"
url = "{{baseUrl}}/getUserProfilePhotos"
headers = HTTP::Headers{
"content-type" => "application/json"
}
reqBody = "{\n \"limit\": 0,\n \"offset\": 0,\n \"user_id\": 0\n}"
response = HTTP::Client.post url, headers: headers, body: reqBody
puts response.body
using System.Net.Http.Headers;
var client = new HttpClient();
var request = new HttpRequestMessage
{
Method = HttpMethod.Post,
RequestUri = new Uri("{{baseUrl}}/getUserProfilePhotos"),
Content = new StringContent("{\n \"limit\": 0,\n \"offset\": 0,\n \"user_id\": 0\n}")
{
Headers =
{
ContentType = new MediaTypeHeaderValue("application/json")
}
}
};
using (var response = await client.SendAsync(request))
{
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
}
var client = new RestClient("{{baseUrl}}/getUserProfilePhotos");
var request = new RestRequest("", Method.Post);
request.AddHeader("content-type", "application/json");
request.AddParameter("application/json", "{\n \"limit\": 0,\n \"offset\": 0,\n \"user_id\": 0\n}", ParameterType.RequestBody);
var response = client.Execute(request);
package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "{{baseUrl}}/getUserProfilePhotos"
payload := strings.NewReader("{\n \"limit\": 0,\n \"offset\": 0,\n \"user_id\": 0\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("content-type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
POST /baseUrl/getUserProfilePhotos HTTP/1.1
Content-Type: application/json
Host: example.com
Content-Length: 47
{
"limit": 0,
"offset": 0,
"user_id": 0
}
AsyncHttpClient client = new DefaultAsyncHttpClient();
client.prepare("POST", "{{baseUrl}}/getUserProfilePhotos")
.setHeader("content-type", "application/json")
.setBody("{\n \"limit\": 0,\n \"offset\": 0,\n \"user_id\": 0\n}")
.execute()
.toCompletableFuture()
.thenAccept(System.out::println)
.join();
client.close();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("{{baseUrl}}/getUserProfilePhotos"))
.header("content-type", "application/json")
.method("POST", HttpRequest.BodyPublishers.ofString("{\n \"limit\": 0,\n \"offset\": 0,\n \"user_id\": 0\n}"))
.build();
HttpResponse response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n \"limit\": 0,\n \"offset\": 0,\n \"user_id\": 0\n}");
Request request = new Request.Builder()
.url("{{baseUrl}}/getUserProfilePhotos")
.post(body)
.addHeader("content-type", "application/json")
.build();
Response response = client.newCall(request).execute();
HttpResponse response = Unirest.post("{{baseUrl}}/getUserProfilePhotos")
.header("content-type", "application/json")
.body("{\n \"limit\": 0,\n \"offset\": 0,\n \"user_id\": 0\n}")
.asString();
const data = JSON.stringify({
limit: 0,
offset: 0,
user_id: 0
});
const xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener('readystatechange', function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open('POST', '{{baseUrl}}/getUserProfilePhotos');
xhr.setRequestHeader('content-type', 'application/json');
xhr.send(data);
import axios from 'axios';
const options = {
method: 'POST',
url: '{{baseUrl}}/getUserProfilePhotos',
headers: {'content-type': 'application/json'},
data: {limit: 0, offset: 0, user_id: 0}
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const url = '{{baseUrl}}/getUserProfilePhotos';
const options = {
method: 'POST',
headers: {'content-type': 'application/json'},
body: '{"limit":0,"offset":0,"user_id":0}'
};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
const settings = {
async: true,
crossDomain: true,
url: '{{baseUrl}}/getUserProfilePhotos',
method: 'POST',
headers: {
'content-type': 'application/json'
},
processData: false,
data: '{\n "limit": 0,\n "offset": 0,\n "user_id": 0\n}'
};
$.ajax(settings).done(function (response) {
console.log(response);
});
val client = OkHttpClient()
val mediaType = MediaType.parse("application/json")
val body = RequestBody.create(mediaType, "{\n \"limit\": 0,\n \"offset\": 0,\n \"user_id\": 0\n}")
val request = Request.Builder()
.url("{{baseUrl}}/getUserProfilePhotos")
.post(body)
.addHeader("content-type", "application/json")
.build()
val response = client.newCall(request).execute()
const http = require('https');
const options = {
method: 'POST',
hostname: 'example.com',
port: null,
path: '/baseUrl/getUserProfilePhotos',
headers: {
'content-type': 'application/json'
}
};
const req = http.request(options, function (res) {
const chunks = [];
res.on('data', function (chunk) {
chunks.push(chunk);
});
res.on('end', function () {
const body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.write(JSON.stringify({limit: 0, offset: 0, user_id: 0}));
req.end();
const request = require('request');
const options = {
method: 'POST',
url: '{{baseUrl}}/getUserProfilePhotos',
headers: {'content-type': 'application/json'},
body: {limit: 0, offset: 0, user_id: 0},
json: true
};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
const unirest = require('unirest');
const req = unirest('POST', '{{baseUrl}}/getUserProfilePhotos');
req.headers({
'content-type': 'application/json'
});
req.type('json');
req.send({
limit: 0,
offset: 0,
user_id: 0
});
req.end(function (res) {
if (res.error) throw new Error(res.error);
console.log(res.body);
});
const axios = require('axios').default;
const options = {
method: 'POST',
url: '{{baseUrl}}/getUserProfilePhotos',
headers: {'content-type': 'application/json'},
data: {limit: 0, offset: 0, user_id: 0}
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const fetch = require('node-fetch');
const url = '{{baseUrl}}/getUserProfilePhotos';
const options = {
method: 'POST',
headers: {'content-type': 'application/json'},
body: '{"limit":0,"offset":0,"user_id":0}'
};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
#import
NSDictionary *headers = @{ @"content-type": @"application/json" };
NSDictionary *parameters = @{ @"limit": @0,
@"offset": @0,
@"user_id": @0 };
NSData *postData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"{{baseUrl}}/getUserProfilePhotos"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
[request setHTTPMethod:@"POST"];
[request setAllHTTPHeaderFields:headers];
[request setHTTPBody:postData];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSLog(@"%@", httpResponse);
}
}];
[dataTask resume];
open Cohttp_lwt_unix
open Cohttp
open Lwt
let uri = Uri.of_string "{{baseUrl}}/getUserProfilePhotos" in
let headers = Header.add (Header.init ()) "content-type" "application/json" in
let body = Cohttp_lwt_body.of_string "{\n \"limit\": 0,\n \"offset\": 0,\n \"user_id\": 0\n}" in
Client.call ~headers ~body `POST uri
>>= fun (res, body_stream) ->
(* Do stuff with the result *)
"{{baseUrl}}/getUserProfilePhotos",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'limit' => 0,
'offset' => 0,
'user_id' => 0
]),
CURLOPT_HTTPHEADER => [
"content-type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
request('POST', '{{baseUrl}}/getUserProfilePhotos', [
'body' => '{
"limit": 0,
"offset": 0,
"user_id": 0
}',
'headers' => [
'content-type' => 'application/json',
],
]);
echo $response->getBody();
setUrl('{{baseUrl}}/getUserProfilePhotos');
$request->setMethod(HTTP_METH_POST);
$request->setHeaders([
'content-type' => 'application/json'
]);
$request->setContentType('application/json');
$request->setBody(json_encode([
'limit' => 0,
'offset' => 0,
'user_id' => 0
]));
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
append(json_encode([
'limit' => 0,
'offset' => 0,
'user_id' => 0
]));
$request->setRequestUrl('{{baseUrl}}/getUserProfilePhotos');
$request->setRequestMethod('POST');
$request->setBody($body);
$request->setHeaders([
'content-type' => 'application/json'
]);
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
$headers=@{}
$headers.Add("content-type", "application/json")
$response = Invoke-WebRequest -Uri '{{baseUrl}}/getUserProfilePhotos' -Method POST -Headers $headers -ContentType 'application/json' -Body '{
"limit": 0,
"offset": 0,
"user_id": 0
}'
$headers=@{}
$headers.Add("content-type", "application/json")
$response = Invoke-RestMethod -Uri '{{baseUrl}}/getUserProfilePhotos' -Method POST -Headers $headers -ContentType 'application/json' -Body '{
"limit": 0,
"offset": 0,
"user_id": 0
}'
import http.client
conn = http.client.HTTPSConnection("example.com")
payload = "{\n \"limit\": 0,\n \"offset\": 0,\n \"user_id\": 0\n}"
headers = { 'content-type': "application/json" }
conn.request("POST", "/baseUrl/getUserProfilePhotos", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
import requests
url = "{{baseUrl}}/getUserProfilePhotos"
payload = {
"limit": 0,
"offset": 0,
"user_id": 0
}
headers = {"content-type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
library(httr)
url <- "{{baseUrl}}/getUserProfilePhotos"
payload <- "{\n \"limit\": 0,\n \"offset\": 0,\n \"user_id\": 0\n}"
encode <- "json"
response <- VERB("POST", url, body = payload, content_type("application/json"), encode = encode)
content(response, "text")
require 'uri'
require 'net/http'
url = URI("{{baseUrl}}/getUserProfilePhotos")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["content-type"] = 'application/json'
request.body = "{\n \"limit\": 0,\n \"offset\": 0,\n \"user_id\": 0\n}"
response = http.request(request)
puts response.read_body
require 'faraday'
conn = Faraday.new(
url: 'https://example.com',
headers: {'Content-Type' => 'application/json'}
)
response = conn.post('/baseUrl/getUserProfilePhotos') do |req|
req.body = "{\n \"limit\": 0,\n \"offset\": 0,\n \"user_id\": 0\n}"
end
puts response.status
puts response.body
use serde_json::json;
use reqwest;
#[tokio::main]
pub async fn main() {
let url = "{{baseUrl}}/getUserProfilePhotos";
let payload = json!({
"limit": 0,
"offset": 0,
"user_id": 0
});
let mut headers = reqwest::header::HeaderMap::new();
headers.insert("content-type", "application/json".parse().unwrap());
let client = reqwest::Client::new();
let response = client.post(url)
.headers(headers)
.json(&payload)
.send()
.await;
let results = response.unwrap()
.json::()
.await
.unwrap();
dbg!(results);
}
curl --request POST \
--url {{baseUrl}}/getUserProfilePhotos \
--header 'content-type: application/json' \
--data '{
"limit": 0,
"offset": 0,
"user_id": 0
}'
echo '{
"limit": 0,
"offset": 0,
"user_id": 0
}' | \
http POST {{baseUrl}}/getUserProfilePhotos \
content-type:application/json
wget --quiet \
--method POST \
--header 'content-type: application/json' \
--body-data '{\n "limit": 0,\n "offset": 0,\n "user_id": 0\n}' \
--output-document \
- {{baseUrl}}/getUserProfilePhotos
import Foundation
let headers = ["content-type": "application/json"]
let parameters = [
"limit": 0,
"offset": 0,
"user_id": 0
] as [String : Any]
let postData = JSONSerialization.data(withJSONObject: parameters, options: [])
let request = NSMutableURLRequest(url: NSURL(string: "{{baseUrl}}/getUserProfilePhotos")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error as Any)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
POST
Use this method to get a sticker set. On success, a [StickerSet](https---core.telegram.org-bots-api-#stickerset) object is returned.
{{baseUrl}}/getStickerSet
BODY json
{
"name": ""
}
Examples
REQUEST
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(hnd, CURLOPT_URL, "{{baseUrl}}/getStickerSet");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "content-type: application/json");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "{\n \"name\": \"\"\n}");
CURLcode ret = curl_easy_perform(hnd);
(require '[clj-http.client :as client])
(client/post "{{baseUrl}}/getStickerSet" {:content-type :json
:form-params {:name ""}})
require "http/client"
url = "{{baseUrl}}/getStickerSet"
headers = HTTP::Headers{
"content-type" => "application/json"
}
reqBody = "{\n \"name\": \"\"\n}"
response = HTTP::Client.post url, headers: headers, body: reqBody
puts response.body
using System.Net.Http.Headers;
var client = new HttpClient();
var request = new HttpRequestMessage
{
Method = HttpMethod.Post,
RequestUri = new Uri("{{baseUrl}}/getStickerSet"),
Content = new StringContent("{\n \"name\": \"\"\n}")
{
Headers =
{
ContentType = new MediaTypeHeaderValue("application/json")
}
}
};
using (var response = await client.SendAsync(request))
{
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
}
var client = new RestClient("{{baseUrl}}/getStickerSet");
var request = new RestRequest("", Method.Post);
request.AddHeader("content-type", "application/json");
request.AddParameter("application/json", "{\n \"name\": \"\"\n}", ParameterType.RequestBody);
var response = client.Execute(request);
package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "{{baseUrl}}/getStickerSet"
payload := strings.NewReader("{\n \"name\": \"\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("content-type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
POST /baseUrl/getStickerSet HTTP/1.1
Content-Type: application/json
Host: example.com
Content-Length: 16
{
"name": ""
}
AsyncHttpClient client = new DefaultAsyncHttpClient();
client.prepare("POST", "{{baseUrl}}/getStickerSet")
.setHeader("content-type", "application/json")
.setBody("{\n \"name\": \"\"\n}")
.execute()
.toCompletableFuture()
.thenAccept(System.out::println)
.join();
client.close();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("{{baseUrl}}/getStickerSet"))
.header("content-type", "application/json")
.method("POST", HttpRequest.BodyPublishers.ofString("{\n \"name\": \"\"\n}"))
.build();
HttpResponse response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n \"name\": \"\"\n}");
Request request = new Request.Builder()
.url("{{baseUrl}}/getStickerSet")
.post(body)
.addHeader("content-type", "application/json")
.build();
Response response = client.newCall(request).execute();
HttpResponse response = Unirest.post("{{baseUrl}}/getStickerSet")
.header("content-type", "application/json")
.body("{\n \"name\": \"\"\n}")
.asString();
const data = JSON.stringify({
name: ''
});
const xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener('readystatechange', function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open('POST', '{{baseUrl}}/getStickerSet');
xhr.setRequestHeader('content-type', 'application/json');
xhr.send(data);
import axios from 'axios';
const options = {
method: 'POST',
url: '{{baseUrl}}/getStickerSet',
headers: {'content-type': 'application/json'},
data: {name: ''}
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const url = '{{baseUrl}}/getStickerSet';
const options = {
method: 'POST',
headers: {'content-type': 'application/json'},
body: '{"name":""}'
};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
const settings = {
async: true,
crossDomain: true,
url: '{{baseUrl}}/getStickerSet',
method: 'POST',
headers: {
'content-type': 'application/json'
},
processData: false,
data: '{\n "name": ""\n}'
};
$.ajax(settings).done(function (response) {
console.log(response);
});
val client = OkHttpClient()
val mediaType = MediaType.parse("application/json")
val body = RequestBody.create(mediaType, "{\n \"name\": \"\"\n}")
val request = Request.Builder()
.url("{{baseUrl}}/getStickerSet")
.post(body)
.addHeader("content-type", "application/json")
.build()
val response = client.newCall(request).execute()
const http = require('https');
const options = {
method: 'POST',
hostname: 'example.com',
port: null,
path: '/baseUrl/getStickerSet',
headers: {
'content-type': 'application/json'
}
};
const req = http.request(options, function (res) {
const chunks = [];
res.on('data', function (chunk) {
chunks.push(chunk);
});
res.on('end', function () {
const body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.write(JSON.stringify({name: ''}));
req.end();
const request = require('request');
const options = {
method: 'POST',
url: '{{baseUrl}}/getStickerSet',
headers: {'content-type': 'application/json'},
body: {name: ''},
json: true
};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
const unirest = require('unirest');
const req = unirest('POST', '{{baseUrl}}/getStickerSet');
req.headers({
'content-type': 'application/json'
});
req.type('json');
req.send({
name: ''
});
req.end(function (res) {
if (res.error) throw new Error(res.error);
console.log(res.body);
});
const axios = require('axios').default;
const options = {
method: 'POST',
url: '{{baseUrl}}/getStickerSet',
headers: {'content-type': 'application/json'},
data: {name: ''}
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const fetch = require('node-fetch');
const url = '{{baseUrl}}/getStickerSet';
const options = {
method: 'POST',
headers: {'content-type': 'application/json'},
body: '{"name":""}'
};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
#import
NSDictionary *headers = @{ @"content-type": @"application/json" };
NSDictionary *parameters = @{ @"name": @"" };
NSData *postData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"{{baseUrl}}/getStickerSet"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
[request setHTTPMethod:@"POST"];
[request setAllHTTPHeaderFields:headers];
[request setHTTPBody:postData];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSLog(@"%@", httpResponse);
}
}];
[dataTask resume];
open Cohttp_lwt_unix
open Cohttp
open Lwt
let uri = Uri.of_string "{{baseUrl}}/getStickerSet" in
let headers = Header.add (Header.init ()) "content-type" "application/json" in
let body = Cohttp_lwt_body.of_string "{\n \"name\": \"\"\n}" in
Client.call ~headers ~body `POST uri
>>= fun (res, body_stream) ->
(* Do stuff with the result *)
"{{baseUrl}}/getStickerSet",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'name' => ''
]),
CURLOPT_HTTPHEADER => [
"content-type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
request('POST', '{{baseUrl}}/getStickerSet', [
'body' => '{
"name": ""
}',
'headers' => [
'content-type' => 'application/json',
],
]);
echo $response->getBody();
setUrl('{{baseUrl}}/getStickerSet');
$request->setMethod(HTTP_METH_POST);
$request->setHeaders([
'content-type' => 'application/json'
]);
$request->setContentType('application/json');
$request->setBody(json_encode([
'name' => ''
]));
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
append(json_encode([
'name' => ''
]));
$request->setRequestUrl('{{baseUrl}}/getStickerSet');
$request->setRequestMethod('POST');
$request->setBody($body);
$request->setHeaders([
'content-type' => 'application/json'
]);
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
$headers=@{}
$headers.Add("content-type", "application/json")
$response = Invoke-WebRequest -Uri '{{baseUrl}}/getStickerSet' -Method POST -Headers $headers -ContentType 'application/json' -Body '{
"name": ""
}'
$headers=@{}
$headers.Add("content-type", "application/json")
$response = Invoke-RestMethod -Uri '{{baseUrl}}/getStickerSet' -Method POST -Headers $headers -ContentType 'application/json' -Body '{
"name": ""
}'
import http.client
conn = http.client.HTTPSConnection("example.com")
payload = "{\n \"name\": \"\"\n}"
headers = { 'content-type': "application/json" }
conn.request("POST", "/baseUrl/getStickerSet", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
import requests
url = "{{baseUrl}}/getStickerSet"
payload = { "name": "" }
headers = {"content-type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
library(httr)
url <- "{{baseUrl}}/getStickerSet"
payload <- "{\n \"name\": \"\"\n}"
encode <- "json"
response <- VERB("POST", url, body = payload, content_type("application/json"), encode = encode)
content(response, "text")
require 'uri'
require 'net/http'
url = URI("{{baseUrl}}/getStickerSet")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["content-type"] = 'application/json'
request.body = "{\n \"name\": \"\"\n}"
response = http.request(request)
puts response.read_body
require 'faraday'
conn = Faraday.new(
url: 'https://example.com',
headers: {'Content-Type' => 'application/json'}
)
response = conn.post('/baseUrl/getStickerSet') do |req|
req.body = "{\n \"name\": \"\"\n}"
end
puts response.status
puts response.body
use serde_json::json;
use reqwest;
#[tokio::main]
pub async fn main() {
let url = "{{baseUrl}}/getStickerSet";
let payload = json!({"name": ""});
let mut headers = reqwest::header::HeaderMap::new();
headers.insert("content-type", "application/json".parse().unwrap());
let client = reqwest::Client::new();
let response = client.post(url)
.headers(headers)
.json(&payload)
.send()
.await;
let results = response.unwrap()
.json::()
.await
.unwrap();
dbg!(results);
}
curl --request POST \
--url {{baseUrl}}/getStickerSet \
--header 'content-type: application/json' \
--data '{
"name": ""
}'
echo '{
"name": ""
}' | \
http POST {{baseUrl}}/getStickerSet \
content-type:application/json
wget --quiet \
--method POST \
--header 'content-type: application/json' \
--body-data '{\n "name": ""\n}' \
--output-document \
- {{baseUrl}}/getStickerSet
import Foundation
let headers = ["content-type": "application/json"]
let parameters = ["name": ""] as [String : Any]
let postData = JSONSerialization.data(withJSONObject: parameters, options: [])
let request = NSMutableURLRequest(url: NSURL(string: "{{baseUrl}}/getStickerSet")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error as Any)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
POST
Use this method to get information about a member of a chat. Returns a [ChatMember](https---core.telegram.org-bots-api-#chatmember) object on success.
{{baseUrl}}/getChatMember
BODY json
{
"chat_id": "",
"user_id": 0
}
Examples
REQUEST
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(hnd, CURLOPT_URL, "{{baseUrl}}/getChatMember");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "content-type: application/json");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "{\n \"chat_id\": \"\",\n \"user_id\": 0\n}");
CURLcode ret = curl_easy_perform(hnd);
(require '[clj-http.client :as client])
(client/post "{{baseUrl}}/getChatMember" {:content-type :json
:form-params {:chat_id ""
:user_id 0}})
require "http/client"
url = "{{baseUrl}}/getChatMember"
headers = HTTP::Headers{
"content-type" => "application/json"
}
reqBody = "{\n \"chat_id\": \"\",\n \"user_id\": 0\n}"
response = HTTP::Client.post url, headers: headers, body: reqBody
puts response.body
using System.Net.Http.Headers;
var client = new HttpClient();
var request = new HttpRequestMessage
{
Method = HttpMethod.Post,
RequestUri = new Uri("{{baseUrl}}/getChatMember"),
Content = new StringContent("{\n \"chat_id\": \"\",\n \"user_id\": 0\n}")
{
Headers =
{
ContentType = new MediaTypeHeaderValue("application/json")
}
}
};
using (var response = await client.SendAsync(request))
{
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
}
var client = new RestClient("{{baseUrl}}/getChatMember");
var request = new RestRequest("", Method.Post);
request.AddHeader("content-type", "application/json");
request.AddParameter("application/json", "{\n \"chat_id\": \"\",\n \"user_id\": 0\n}", ParameterType.RequestBody);
var response = client.Execute(request);
package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "{{baseUrl}}/getChatMember"
payload := strings.NewReader("{\n \"chat_id\": \"\",\n \"user_id\": 0\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("content-type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
POST /baseUrl/getChatMember HTTP/1.1
Content-Type: application/json
Host: example.com
Content-Length: 35
{
"chat_id": "",
"user_id": 0
}
AsyncHttpClient client = new DefaultAsyncHttpClient();
client.prepare("POST", "{{baseUrl}}/getChatMember")
.setHeader("content-type", "application/json")
.setBody("{\n \"chat_id\": \"\",\n \"user_id\": 0\n}")
.execute()
.toCompletableFuture()
.thenAccept(System.out::println)
.join();
client.close();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("{{baseUrl}}/getChatMember"))
.header("content-type", "application/json")
.method("POST", HttpRequest.BodyPublishers.ofString("{\n \"chat_id\": \"\",\n \"user_id\": 0\n}"))
.build();
HttpResponse response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n \"chat_id\": \"\",\n \"user_id\": 0\n}");
Request request = new Request.Builder()
.url("{{baseUrl}}/getChatMember")
.post(body)
.addHeader("content-type", "application/json")
.build();
Response response = client.newCall(request).execute();
HttpResponse response = Unirest.post("{{baseUrl}}/getChatMember")
.header("content-type", "application/json")
.body("{\n \"chat_id\": \"\",\n \"user_id\": 0\n}")
.asString();
const data = JSON.stringify({
chat_id: '',
user_id: 0
});
const xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener('readystatechange', function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open('POST', '{{baseUrl}}/getChatMember');
xhr.setRequestHeader('content-type', 'application/json');
xhr.send(data);
import axios from 'axios';
const options = {
method: 'POST',
url: '{{baseUrl}}/getChatMember',
headers: {'content-type': 'application/json'},
data: {chat_id: '', user_id: 0}
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const url = '{{baseUrl}}/getChatMember';
const options = {
method: 'POST',
headers: {'content-type': 'application/json'},
body: '{"chat_id":"","user_id":0}'
};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
const settings = {
async: true,
crossDomain: true,
url: '{{baseUrl}}/getChatMember',
method: 'POST',
headers: {
'content-type': 'application/json'
},
processData: false,
data: '{\n "chat_id": "",\n "user_id": 0\n}'
};
$.ajax(settings).done(function (response) {
console.log(response);
});
val client = OkHttpClient()
val mediaType = MediaType.parse("application/json")
val body = RequestBody.create(mediaType, "{\n \"chat_id\": \"\",\n \"user_id\": 0\n}")
val request = Request.Builder()
.url("{{baseUrl}}/getChatMember")
.post(body)
.addHeader("content-type", "application/json")
.build()
val response = client.newCall(request).execute()
const http = require('https');
const options = {
method: 'POST',
hostname: 'example.com',
port: null,
path: '/baseUrl/getChatMember',
headers: {
'content-type': 'application/json'
}
};
const req = http.request(options, function (res) {
const chunks = [];
res.on('data', function (chunk) {
chunks.push(chunk);
});
res.on('end', function () {
const body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.write(JSON.stringify({chat_id: '', user_id: 0}));
req.end();
const request = require('request');
const options = {
method: 'POST',
url: '{{baseUrl}}/getChatMember',
headers: {'content-type': 'application/json'},
body: {chat_id: '', user_id: 0},
json: true
};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
const unirest = require('unirest');
const req = unirest('POST', '{{baseUrl}}/getChatMember');
req.headers({
'content-type': 'application/json'
});
req.type('json');
req.send({
chat_id: '',
user_id: 0
});
req.end(function (res) {
if (res.error) throw new Error(res.error);
console.log(res.body);
});
const axios = require('axios').default;
const options = {
method: 'POST',
url: '{{baseUrl}}/getChatMember',
headers: {'content-type': 'application/json'},
data: {chat_id: '', user_id: 0}
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const fetch = require('node-fetch');
const url = '{{baseUrl}}/getChatMember';
const options = {
method: 'POST',
headers: {'content-type': 'application/json'},
body: '{"chat_id":"","user_id":0}'
};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
#import
NSDictionary *headers = @{ @"content-type": @"application/json" };
NSDictionary *parameters = @{ @"chat_id": @"",
@"user_id": @0 };
NSData *postData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"{{baseUrl}}/getChatMember"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
[request setHTTPMethod:@"POST"];
[request setAllHTTPHeaderFields:headers];
[request setHTTPBody:postData];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSLog(@"%@", httpResponse);
}
}];
[dataTask resume];
open Cohttp_lwt_unix
open Cohttp
open Lwt
let uri = Uri.of_string "{{baseUrl}}/getChatMember" in
let headers = Header.add (Header.init ()) "content-type" "application/json" in
let body = Cohttp_lwt_body.of_string "{\n \"chat_id\": \"\",\n \"user_id\": 0\n}" in
Client.call ~headers ~body `POST uri
>>= fun (res, body_stream) ->
(* Do stuff with the result *)
"{{baseUrl}}/getChatMember",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'chat_id' => '',
'user_id' => 0
]),
CURLOPT_HTTPHEADER => [
"content-type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
request('POST', '{{baseUrl}}/getChatMember', [
'body' => '{
"chat_id": "",
"user_id": 0
}',
'headers' => [
'content-type' => 'application/json',
],
]);
echo $response->getBody();
setUrl('{{baseUrl}}/getChatMember');
$request->setMethod(HTTP_METH_POST);
$request->setHeaders([
'content-type' => 'application/json'
]);
$request->setContentType('application/json');
$request->setBody(json_encode([
'chat_id' => '',
'user_id' => 0
]));
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
append(json_encode([
'chat_id' => '',
'user_id' => 0
]));
$request->setRequestUrl('{{baseUrl}}/getChatMember');
$request->setRequestMethod('POST');
$request->setBody($body);
$request->setHeaders([
'content-type' => 'application/json'
]);
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
$headers=@{}
$headers.Add("content-type", "application/json")
$response = Invoke-WebRequest -Uri '{{baseUrl}}/getChatMember' -Method POST -Headers $headers -ContentType 'application/json' -Body '{
"chat_id": "",
"user_id": 0
}'
$headers=@{}
$headers.Add("content-type", "application/json")
$response = Invoke-RestMethod -Uri '{{baseUrl}}/getChatMember' -Method POST -Headers $headers -ContentType 'application/json' -Body '{
"chat_id": "",
"user_id": 0
}'
import http.client
conn = http.client.HTTPSConnection("example.com")
payload = "{\n \"chat_id\": \"\",\n \"user_id\": 0\n}"
headers = { 'content-type': "application/json" }
conn.request("POST", "/baseUrl/getChatMember", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
import requests
url = "{{baseUrl}}/getChatMember"
payload = {
"chat_id": "",
"user_id": 0
}
headers = {"content-type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
library(httr)
url <- "{{baseUrl}}/getChatMember"
payload <- "{\n \"chat_id\": \"\",\n \"user_id\": 0\n}"
encode <- "json"
response <- VERB("POST", url, body = payload, content_type("application/json"), encode = encode)
content(response, "text")
require 'uri'
require 'net/http'
url = URI("{{baseUrl}}/getChatMember")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["content-type"] = 'application/json'
request.body = "{\n \"chat_id\": \"\",\n \"user_id\": 0\n}"
response = http.request(request)
puts response.read_body
require 'faraday'
conn = Faraday.new(
url: 'https://example.com',
headers: {'Content-Type' => 'application/json'}
)
response = conn.post('/baseUrl/getChatMember') do |req|
req.body = "{\n \"chat_id\": \"\",\n \"user_id\": 0\n}"
end
puts response.status
puts response.body
use serde_json::json;
use reqwest;
#[tokio::main]
pub async fn main() {
let url = "{{baseUrl}}/getChatMember";
let payload = json!({
"chat_id": "",
"user_id": 0
});
let mut headers = reqwest::header::HeaderMap::new();
headers.insert("content-type", "application/json".parse().unwrap());
let client = reqwest::Client::new();
let response = client.post(url)
.headers(headers)
.json(&payload)
.send()
.await;
let results = response.unwrap()
.json::()
.await
.unwrap();
dbg!(results);
}
curl --request POST \
--url {{baseUrl}}/getChatMember \
--header 'content-type: application/json' \
--data '{
"chat_id": "",
"user_id": 0
}'
echo '{
"chat_id": "",
"user_id": 0
}' | \
http POST {{baseUrl}}/getChatMember \
content-type:application/json
wget --quiet \
--method POST \
--header 'content-type: application/json' \
--body-data '{\n "chat_id": "",\n "user_id": 0\n}' \
--output-document \
- {{baseUrl}}/getChatMember
import Foundation
let headers = ["content-type": "application/json"]
let parameters = [
"chat_id": "",
"user_id": 0
] as [String : Any]
let postData = JSONSerialization.data(withJSONObject: parameters, options: [])
let request = NSMutableURLRequest(url: NSURL(string: "{{baseUrl}}/getChatMember")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error as Any)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
POST
Use this method to get the current list of the bot's commands. Requires no parameters. Returns Array of [BotCommand](https---core.telegram.org-bots-api-#botcommand) on success.
{{baseUrl}}/getMyCommands
Examples
REQUEST
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(hnd, CURLOPT_URL, "{{baseUrl}}/getMyCommands");
CURLcode ret = curl_easy_perform(hnd);
(require '[clj-http.client :as client])
(client/post "{{baseUrl}}/getMyCommands")
require "http/client"
url = "{{baseUrl}}/getMyCommands"
response = HTTP::Client.post url
puts response.body
using System.Net.Http.Headers;
var client = new HttpClient();
var request = new HttpRequestMessage
{
Method = HttpMethod.Post,
RequestUri = new Uri("{{baseUrl}}/getMyCommands"),
};
using (var response = await client.SendAsync(request))
{
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
}
var client = new RestClient("{{baseUrl}}/getMyCommands");
var request = new RestRequest("", Method.Post);
var response = client.Execute(request);
package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "{{baseUrl}}/getMyCommands"
req, _ := http.NewRequest("POST", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
POST /baseUrl/getMyCommands HTTP/1.1
Host: example.com
AsyncHttpClient client = new DefaultAsyncHttpClient();
client.prepare("POST", "{{baseUrl}}/getMyCommands")
.execute()
.toCompletableFuture()
.thenAccept(System.out::println)
.join();
client.close();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("{{baseUrl}}/getMyCommands"))
.method("POST", HttpRequest.BodyPublishers.noBody())
.build();
HttpResponse response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url("{{baseUrl}}/getMyCommands")
.post(null)
.build();
Response response = client.newCall(request).execute();
HttpResponse response = Unirest.post("{{baseUrl}}/getMyCommands")
.asString();
const data = null;
const xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener('readystatechange', function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open('POST', '{{baseUrl}}/getMyCommands');
xhr.send(data);
import axios from 'axios';
const options = {method: 'POST', url: '{{baseUrl}}/getMyCommands'};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const url = '{{baseUrl}}/getMyCommands';
const options = {method: 'POST'};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
const settings = {
async: true,
crossDomain: true,
url: '{{baseUrl}}/getMyCommands',
method: 'POST',
headers: {}
};
$.ajax(settings).done(function (response) {
console.log(response);
});
val client = OkHttpClient()
val request = Request.Builder()
.url("{{baseUrl}}/getMyCommands")
.post(null)
.build()
val response = client.newCall(request).execute()
const http = require('https');
const options = {
method: 'POST',
hostname: 'example.com',
port: null,
path: '/baseUrl/getMyCommands',
headers: {}
};
const req = http.request(options, function (res) {
const chunks = [];
res.on('data', function (chunk) {
chunks.push(chunk);
});
res.on('end', function () {
const body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.end();
const request = require('request');
const options = {method: 'POST', url: '{{baseUrl}}/getMyCommands'};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
const unirest = require('unirest');
const req = unirest('POST', '{{baseUrl}}/getMyCommands');
req.end(function (res) {
if (res.error) throw new Error(res.error);
console.log(res.body);
});
const axios = require('axios').default;
const options = {method: 'POST', url: '{{baseUrl}}/getMyCommands'};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const fetch = require('node-fetch');
const url = '{{baseUrl}}/getMyCommands';
const options = {method: 'POST'};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
#import
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"{{baseUrl}}/getMyCommands"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
[request setHTTPMethod:@"POST"];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSLog(@"%@", httpResponse);
}
}];
[dataTask resume];
open Cohttp_lwt_unix
open Cohttp
open Lwt
let uri = Uri.of_string "{{baseUrl}}/getMyCommands" in
Client.call `POST uri
>>= fun (res, body_stream) ->
(* Do stuff with the result *)
"{{baseUrl}}/getMyCommands",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
request('POST', '{{baseUrl}}/getMyCommands');
echo $response->getBody();
setUrl('{{baseUrl}}/getMyCommands');
$request->setMethod(HTTP_METH_POST);
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
setRequestUrl('{{baseUrl}}/getMyCommands');
$request->setRequestMethod('POST');
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
$response = Invoke-WebRequest -Uri '{{baseUrl}}/getMyCommands' -Method POST
$response = Invoke-RestMethod -Uri '{{baseUrl}}/getMyCommands' -Method POST
import http.client
conn = http.client.HTTPSConnection("example.com")
conn.request("POST", "/baseUrl/getMyCommands")
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
import requests
url = "{{baseUrl}}/getMyCommands"
response = requests.post(url)
print(response.json())
library(httr)
url <- "{{baseUrl}}/getMyCommands"
response <- VERB("POST", url, content_type("application/octet-stream"))
content(response, "text")
require 'uri'
require 'net/http'
url = URI("{{baseUrl}}/getMyCommands")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
response = http.request(request)
puts response.read_body
require 'faraday'
conn = Faraday.new(
url: 'https://example.com',
)
response = conn.post('/baseUrl/getMyCommands') do |req|
end
puts response.status
puts response.body
use reqwest;
#[tokio::main]
pub async fn main() {
let url = "{{baseUrl}}/getMyCommands";
let client = reqwest::Client::new();
let response = client.post(url)
.send()
.await;
let results = response.unwrap()
.json::()
.await
.unwrap();
dbg!(results);
}
curl --request POST \
--url {{baseUrl}}/getMyCommands
http POST {{baseUrl}}/getMyCommands
wget --quiet \
--method POST \
--output-document \
- {{baseUrl}}/getMyCommands
import Foundation
let request = NSMutableURLRequest(url: NSURL(string: "{{baseUrl}}/getMyCommands")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "POST"
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error as Any)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
POST
Use this method to get the number of members in a chat. Returns -Int- on success.
{{baseUrl}}/getChatMembersCount
BODY json
{
"chat_id": ""
}
Examples
REQUEST
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(hnd, CURLOPT_URL, "{{baseUrl}}/getChatMembersCount");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "content-type: application/json");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "{\n \"chat_id\": \"\"\n}");
CURLcode ret = curl_easy_perform(hnd);
(require '[clj-http.client :as client])
(client/post "{{baseUrl}}/getChatMembersCount" {:content-type :json
:form-params {:chat_id ""}})
require "http/client"
url = "{{baseUrl}}/getChatMembersCount"
headers = HTTP::Headers{
"content-type" => "application/json"
}
reqBody = "{\n \"chat_id\": \"\"\n}"
response = HTTP::Client.post url, headers: headers, body: reqBody
puts response.body
using System.Net.Http.Headers;
var client = new HttpClient();
var request = new HttpRequestMessage
{
Method = HttpMethod.Post,
RequestUri = new Uri("{{baseUrl}}/getChatMembersCount"),
Content = new StringContent("{\n \"chat_id\": \"\"\n}")
{
Headers =
{
ContentType = new MediaTypeHeaderValue("application/json")
}
}
};
using (var response = await client.SendAsync(request))
{
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
}
var client = new RestClient("{{baseUrl}}/getChatMembersCount");
var request = new RestRequest("", Method.Post);
request.AddHeader("content-type", "application/json");
request.AddParameter("application/json", "{\n \"chat_id\": \"\"\n}", ParameterType.RequestBody);
var response = client.Execute(request);
package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "{{baseUrl}}/getChatMembersCount"
payload := strings.NewReader("{\n \"chat_id\": \"\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("content-type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
POST /baseUrl/getChatMembersCount HTTP/1.1
Content-Type: application/json
Host: example.com
Content-Length: 19
{
"chat_id": ""
}
AsyncHttpClient client = new DefaultAsyncHttpClient();
client.prepare("POST", "{{baseUrl}}/getChatMembersCount")
.setHeader("content-type", "application/json")
.setBody("{\n \"chat_id\": \"\"\n}")
.execute()
.toCompletableFuture()
.thenAccept(System.out::println)
.join();
client.close();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("{{baseUrl}}/getChatMembersCount"))
.header("content-type", "application/json")
.method("POST", HttpRequest.BodyPublishers.ofString("{\n \"chat_id\": \"\"\n}"))
.build();
HttpResponse response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n \"chat_id\": \"\"\n}");
Request request = new Request.Builder()
.url("{{baseUrl}}/getChatMembersCount")
.post(body)
.addHeader("content-type", "application/json")
.build();
Response response = client.newCall(request).execute();
HttpResponse response = Unirest.post("{{baseUrl}}/getChatMembersCount")
.header("content-type", "application/json")
.body("{\n \"chat_id\": \"\"\n}")
.asString();
const data = JSON.stringify({
chat_id: ''
});
const xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener('readystatechange', function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open('POST', '{{baseUrl}}/getChatMembersCount');
xhr.setRequestHeader('content-type', 'application/json');
xhr.send(data);
import axios from 'axios';
const options = {
method: 'POST',
url: '{{baseUrl}}/getChatMembersCount',
headers: {'content-type': 'application/json'},
data: {chat_id: ''}
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const url = '{{baseUrl}}/getChatMembersCount';
const options = {
method: 'POST',
headers: {'content-type': 'application/json'},
body: '{"chat_id":""}'
};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
const settings = {
async: true,
crossDomain: true,
url: '{{baseUrl}}/getChatMembersCount',
method: 'POST',
headers: {
'content-type': 'application/json'
},
processData: false,
data: '{\n "chat_id": ""\n}'
};
$.ajax(settings).done(function (response) {
console.log(response);
});
val client = OkHttpClient()
val mediaType = MediaType.parse("application/json")
val body = RequestBody.create(mediaType, "{\n \"chat_id\": \"\"\n}")
val request = Request.Builder()
.url("{{baseUrl}}/getChatMembersCount")
.post(body)
.addHeader("content-type", "application/json")
.build()
val response = client.newCall(request).execute()
const http = require('https');
const options = {
method: 'POST',
hostname: 'example.com',
port: null,
path: '/baseUrl/getChatMembersCount',
headers: {
'content-type': 'application/json'
}
};
const req = http.request(options, function (res) {
const chunks = [];
res.on('data', function (chunk) {
chunks.push(chunk);
});
res.on('end', function () {
const body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.write(JSON.stringify({chat_id: ''}));
req.end();
const request = require('request');
const options = {
method: 'POST',
url: '{{baseUrl}}/getChatMembersCount',
headers: {'content-type': 'application/json'},
body: {chat_id: ''},
json: true
};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
const unirest = require('unirest');
const req = unirest('POST', '{{baseUrl}}/getChatMembersCount');
req.headers({
'content-type': 'application/json'
});
req.type('json');
req.send({
chat_id: ''
});
req.end(function (res) {
if (res.error) throw new Error(res.error);
console.log(res.body);
});
const axios = require('axios').default;
const options = {
method: 'POST',
url: '{{baseUrl}}/getChatMembersCount',
headers: {'content-type': 'application/json'},
data: {chat_id: ''}
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const fetch = require('node-fetch');
const url = '{{baseUrl}}/getChatMembersCount';
const options = {
method: 'POST',
headers: {'content-type': 'application/json'},
body: '{"chat_id":""}'
};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
#import
NSDictionary *headers = @{ @"content-type": @"application/json" };
NSDictionary *parameters = @{ @"chat_id": @"" };
NSData *postData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"{{baseUrl}}/getChatMembersCount"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
[request setHTTPMethod:@"POST"];
[request setAllHTTPHeaderFields:headers];
[request setHTTPBody:postData];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSLog(@"%@", httpResponse);
}
}];
[dataTask resume];
open Cohttp_lwt_unix
open Cohttp
open Lwt
let uri = Uri.of_string "{{baseUrl}}/getChatMembersCount" in
let headers = Header.add (Header.init ()) "content-type" "application/json" in
let body = Cohttp_lwt_body.of_string "{\n \"chat_id\": \"\"\n}" in
Client.call ~headers ~body `POST uri
>>= fun (res, body_stream) ->
(* Do stuff with the result *)
"{{baseUrl}}/getChatMembersCount",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'chat_id' => ''
]),
CURLOPT_HTTPHEADER => [
"content-type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
request('POST', '{{baseUrl}}/getChatMembersCount', [
'body' => '{
"chat_id": ""
}',
'headers' => [
'content-type' => 'application/json',
],
]);
echo $response->getBody();
setUrl('{{baseUrl}}/getChatMembersCount');
$request->setMethod(HTTP_METH_POST);
$request->setHeaders([
'content-type' => 'application/json'
]);
$request->setContentType('application/json');
$request->setBody(json_encode([
'chat_id' => ''
]));
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
append(json_encode([
'chat_id' => ''
]));
$request->setRequestUrl('{{baseUrl}}/getChatMembersCount');
$request->setRequestMethod('POST');
$request->setBody($body);
$request->setHeaders([
'content-type' => 'application/json'
]);
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
$headers=@{}
$headers.Add("content-type", "application/json")
$response = Invoke-WebRequest -Uri '{{baseUrl}}/getChatMembersCount' -Method POST -Headers $headers -ContentType 'application/json' -Body '{
"chat_id": ""
}'
$headers=@{}
$headers.Add("content-type", "application/json")
$response = Invoke-RestMethod -Uri '{{baseUrl}}/getChatMembersCount' -Method POST -Headers $headers -ContentType 'application/json' -Body '{
"chat_id": ""
}'
import http.client
conn = http.client.HTTPSConnection("example.com")
payload = "{\n \"chat_id\": \"\"\n}"
headers = { 'content-type': "application/json" }
conn.request("POST", "/baseUrl/getChatMembersCount", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
import requests
url = "{{baseUrl}}/getChatMembersCount"
payload = { "chat_id": "" }
headers = {"content-type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
library(httr)
url <- "{{baseUrl}}/getChatMembersCount"
payload <- "{\n \"chat_id\": \"\"\n}"
encode <- "json"
response <- VERB("POST", url, body = payload, content_type("application/json"), encode = encode)
content(response, "text")
require 'uri'
require 'net/http'
url = URI("{{baseUrl}}/getChatMembersCount")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["content-type"] = 'application/json'
request.body = "{\n \"chat_id\": \"\"\n}"
response = http.request(request)
puts response.read_body
require 'faraday'
conn = Faraday.new(
url: 'https://example.com',
headers: {'Content-Type' => 'application/json'}
)
response = conn.post('/baseUrl/getChatMembersCount') do |req|
req.body = "{\n \"chat_id\": \"\"\n}"
end
puts response.status
puts response.body
use serde_json::json;
use reqwest;
#[tokio::main]
pub async fn main() {
let url = "{{baseUrl}}/getChatMembersCount";
let payload = json!({"chat_id": ""});
let mut headers = reqwest::header::HeaderMap::new();
headers.insert("content-type", "application/json".parse().unwrap());
let client = reqwest::Client::new();
let response = client.post(url)
.headers(headers)
.json(&payload)
.send()
.await;
let results = response.unwrap()
.json::()
.await
.unwrap();
dbg!(results);
}
curl --request POST \
--url {{baseUrl}}/getChatMembersCount \
--header 'content-type: application/json' \
--data '{
"chat_id": ""
}'
echo '{
"chat_id": ""
}' | \
http POST {{baseUrl}}/getChatMembersCount \
content-type:application/json
wget --quiet \
--method POST \
--header 'content-type: application/json' \
--body-data '{\n "chat_id": ""\n}' \
--output-document \
- {{baseUrl}}/getChatMembersCount
import Foundation
let headers = ["content-type": "application/json"]
let parameters = ["chat_id": ""] as [String : Any]
let postData = JSONSerialization.data(withJSONObject: parameters, options: [])
let request = NSMutableURLRequest(url: NSURL(string: "{{baseUrl}}/getChatMembersCount")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error as Any)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
POST
Use this method to get up to date information about the chat (current name of the user for one-on-one conversations, current username of a user, group or channel, etc.). Returns a [Chat](https---core.telegram.org-bots-api-#chat) object on success.
{{baseUrl}}/getChat
BODY json
{
"chat_id": ""
}
Examples
REQUEST
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(hnd, CURLOPT_URL, "{{baseUrl}}/getChat");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "content-type: application/json");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "{\n \"chat_id\": \"\"\n}");
CURLcode ret = curl_easy_perform(hnd);
(require '[clj-http.client :as client])
(client/post "{{baseUrl}}/getChat" {:content-type :json
:form-params {:chat_id ""}})
require "http/client"
url = "{{baseUrl}}/getChat"
headers = HTTP::Headers{
"content-type" => "application/json"
}
reqBody = "{\n \"chat_id\": \"\"\n}"
response = HTTP::Client.post url, headers: headers, body: reqBody
puts response.body
using System.Net.Http.Headers;
var client = new HttpClient();
var request = new HttpRequestMessage
{
Method = HttpMethod.Post,
RequestUri = new Uri("{{baseUrl}}/getChat"),
Content = new StringContent("{\n \"chat_id\": \"\"\n}")
{
Headers =
{
ContentType = new MediaTypeHeaderValue("application/json")
}
}
};
using (var response = await client.SendAsync(request))
{
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
}
var client = new RestClient("{{baseUrl}}/getChat");
var request = new RestRequest("", Method.Post);
request.AddHeader("content-type", "application/json");
request.AddParameter("application/json", "{\n \"chat_id\": \"\"\n}", ParameterType.RequestBody);
var response = client.Execute(request);
package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "{{baseUrl}}/getChat"
payload := strings.NewReader("{\n \"chat_id\": \"\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("content-type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
POST /baseUrl/getChat HTTP/1.1
Content-Type: application/json
Host: example.com
Content-Length: 19
{
"chat_id": ""
}
AsyncHttpClient client = new DefaultAsyncHttpClient();
client.prepare("POST", "{{baseUrl}}/getChat")
.setHeader("content-type", "application/json")
.setBody("{\n \"chat_id\": \"\"\n}")
.execute()
.toCompletableFuture()
.thenAccept(System.out::println)
.join();
client.close();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("{{baseUrl}}/getChat"))
.header("content-type", "application/json")
.method("POST", HttpRequest.BodyPublishers.ofString("{\n \"chat_id\": \"\"\n}"))
.build();
HttpResponse response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n \"chat_id\": \"\"\n}");
Request request = new Request.Builder()
.url("{{baseUrl}}/getChat")
.post(body)
.addHeader("content-type", "application/json")
.build();
Response response = client.newCall(request).execute();
HttpResponse response = Unirest.post("{{baseUrl}}/getChat")
.header("content-type", "application/json")
.body("{\n \"chat_id\": \"\"\n}")
.asString();
const data = JSON.stringify({
chat_id: ''
});
const xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener('readystatechange', function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open('POST', '{{baseUrl}}/getChat');
xhr.setRequestHeader('content-type', 'application/json');
xhr.send(data);
import axios from 'axios';
const options = {
method: 'POST',
url: '{{baseUrl}}/getChat',
headers: {'content-type': 'application/json'},
data: {chat_id: ''}
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const url = '{{baseUrl}}/getChat';
const options = {
method: 'POST',
headers: {'content-type': 'application/json'},
body: '{"chat_id":""}'
};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
const settings = {
async: true,
crossDomain: true,
url: '{{baseUrl}}/getChat',
method: 'POST',
headers: {
'content-type': 'application/json'
},
processData: false,
data: '{\n "chat_id": ""\n}'
};
$.ajax(settings).done(function (response) {
console.log(response);
});
val client = OkHttpClient()
val mediaType = MediaType.parse("application/json")
val body = RequestBody.create(mediaType, "{\n \"chat_id\": \"\"\n}")
val request = Request.Builder()
.url("{{baseUrl}}/getChat")
.post(body)
.addHeader("content-type", "application/json")
.build()
val response = client.newCall(request).execute()
const http = require('https');
const options = {
method: 'POST',
hostname: 'example.com',
port: null,
path: '/baseUrl/getChat',
headers: {
'content-type': 'application/json'
}
};
const req = http.request(options, function (res) {
const chunks = [];
res.on('data', function (chunk) {
chunks.push(chunk);
});
res.on('end', function () {
const body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.write(JSON.stringify({chat_id: ''}));
req.end();
const request = require('request');
const options = {
method: 'POST',
url: '{{baseUrl}}/getChat',
headers: {'content-type': 'application/json'},
body: {chat_id: ''},
json: true
};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
const unirest = require('unirest');
const req = unirest('POST', '{{baseUrl}}/getChat');
req.headers({
'content-type': 'application/json'
});
req.type('json');
req.send({
chat_id: ''
});
req.end(function (res) {
if (res.error) throw new Error(res.error);
console.log(res.body);
});
const axios = require('axios').default;
const options = {
method: 'POST',
url: '{{baseUrl}}/getChat',
headers: {'content-type': 'application/json'},
data: {chat_id: ''}
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const fetch = require('node-fetch');
const url = '{{baseUrl}}/getChat';
const options = {
method: 'POST',
headers: {'content-type': 'application/json'},
body: '{"chat_id":""}'
};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
#import
NSDictionary *headers = @{ @"content-type": @"application/json" };
NSDictionary *parameters = @{ @"chat_id": @"" };
NSData *postData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"{{baseUrl}}/getChat"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
[request setHTTPMethod:@"POST"];
[request setAllHTTPHeaderFields:headers];
[request setHTTPBody:postData];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSLog(@"%@", httpResponse);
}
}];
[dataTask resume];
open Cohttp_lwt_unix
open Cohttp
open Lwt
let uri = Uri.of_string "{{baseUrl}}/getChat" in
let headers = Header.add (Header.init ()) "content-type" "application/json" in
let body = Cohttp_lwt_body.of_string "{\n \"chat_id\": \"\"\n}" in
Client.call ~headers ~body `POST uri
>>= fun (res, body_stream) ->
(* Do stuff with the result *)
"{{baseUrl}}/getChat",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'chat_id' => ''
]),
CURLOPT_HTTPHEADER => [
"content-type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
request('POST', '{{baseUrl}}/getChat', [
'body' => '{
"chat_id": ""
}',
'headers' => [
'content-type' => 'application/json',
],
]);
echo $response->getBody();
setUrl('{{baseUrl}}/getChat');
$request->setMethod(HTTP_METH_POST);
$request->setHeaders([
'content-type' => 'application/json'
]);
$request->setContentType('application/json');
$request->setBody(json_encode([
'chat_id' => ''
]));
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
append(json_encode([
'chat_id' => ''
]));
$request->setRequestUrl('{{baseUrl}}/getChat');
$request->setRequestMethod('POST');
$request->setBody($body);
$request->setHeaders([
'content-type' => 'application/json'
]);
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
$headers=@{}
$headers.Add("content-type", "application/json")
$response = Invoke-WebRequest -Uri '{{baseUrl}}/getChat' -Method POST -Headers $headers -ContentType 'application/json' -Body '{
"chat_id": ""
}'
$headers=@{}
$headers.Add("content-type", "application/json")
$response = Invoke-RestMethod -Uri '{{baseUrl}}/getChat' -Method POST -Headers $headers -ContentType 'application/json' -Body '{
"chat_id": ""
}'
import http.client
conn = http.client.HTTPSConnection("example.com")
payload = "{\n \"chat_id\": \"\"\n}"
headers = { 'content-type': "application/json" }
conn.request("POST", "/baseUrl/getChat", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
import requests
url = "{{baseUrl}}/getChat"
payload = { "chat_id": "" }
headers = {"content-type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
library(httr)
url <- "{{baseUrl}}/getChat"
payload <- "{\n \"chat_id\": \"\"\n}"
encode <- "json"
response <- VERB("POST", url, body = payload, content_type("application/json"), encode = encode)
content(response, "text")
require 'uri'
require 'net/http'
url = URI("{{baseUrl}}/getChat")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["content-type"] = 'application/json'
request.body = "{\n \"chat_id\": \"\"\n}"
response = http.request(request)
puts response.read_body
require 'faraday'
conn = Faraday.new(
url: 'https://example.com',
headers: {'Content-Type' => 'application/json'}
)
response = conn.post('/baseUrl/getChat') do |req|
req.body = "{\n \"chat_id\": \"\"\n}"
end
puts response.status
puts response.body
use serde_json::json;
use reqwest;
#[tokio::main]
pub async fn main() {
let url = "{{baseUrl}}/getChat";
let payload = json!({"chat_id": ""});
let mut headers = reqwest::header::HeaderMap::new();
headers.insert("content-type", "application/json".parse().unwrap());
let client = reqwest::Client::new();
let response = client.post(url)
.headers(headers)
.json(&payload)
.send()
.await;
let results = response.unwrap()
.json::()
.await
.unwrap();
dbg!(results);
}
curl --request POST \
--url {{baseUrl}}/getChat \
--header 'content-type: application/json' \
--data '{
"chat_id": ""
}'
echo '{
"chat_id": ""
}' | \
http POST {{baseUrl}}/getChat \
content-type:application/json
wget --quiet \
--method POST \
--header 'content-type: application/json' \
--body-data '{\n "chat_id": ""\n}' \
--output-document \
- {{baseUrl}}/getChat
import Foundation
let headers = ["content-type": "application/json"]
let parameters = ["chat_id": ""] as [String : Any]
let postData = JSONSerialization.data(withJSONObject: parameters, options: [])
let request = NSMutableURLRequest(url: NSURL(string: "{{baseUrl}}/getChat")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error as Any)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
POST
Use this method to move a sticker in a set created by the bot to a specific position. Returns -True- on success.
{{baseUrl}}/setStickerPositionInSet
BODY json
{
"position": 0,
"sticker": ""
}
Examples
REQUEST
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(hnd, CURLOPT_URL, "{{baseUrl}}/setStickerPositionInSet");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "content-type: application/json");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "{\n \"position\": 0,\n \"sticker\": \"\"\n}");
CURLcode ret = curl_easy_perform(hnd);
(require '[clj-http.client :as client])
(client/post "{{baseUrl}}/setStickerPositionInSet" {:content-type :json
:form-params {:position 0
:sticker ""}})
require "http/client"
url = "{{baseUrl}}/setStickerPositionInSet"
headers = HTTP::Headers{
"content-type" => "application/json"
}
reqBody = "{\n \"position\": 0,\n \"sticker\": \"\"\n}"
response = HTTP::Client.post url, headers: headers, body: reqBody
puts response.body
using System.Net.Http.Headers;
var client = new HttpClient();
var request = new HttpRequestMessage
{
Method = HttpMethod.Post,
RequestUri = new Uri("{{baseUrl}}/setStickerPositionInSet"),
Content = new StringContent("{\n \"position\": 0,\n \"sticker\": \"\"\n}")
{
Headers =
{
ContentType = new MediaTypeHeaderValue("application/json")
}
}
};
using (var response = await client.SendAsync(request))
{
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
}
var client = new RestClient("{{baseUrl}}/setStickerPositionInSet");
var request = new RestRequest("", Method.Post);
request.AddHeader("content-type", "application/json");
request.AddParameter("application/json", "{\n \"position\": 0,\n \"sticker\": \"\"\n}", ParameterType.RequestBody);
var response = client.Execute(request);
package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "{{baseUrl}}/setStickerPositionInSet"
payload := strings.NewReader("{\n \"position\": 0,\n \"sticker\": \"\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("content-type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
POST /baseUrl/setStickerPositionInSet HTTP/1.1
Content-Type: application/json
Host: example.com
Content-Length: 36
{
"position": 0,
"sticker": ""
}
AsyncHttpClient client = new DefaultAsyncHttpClient();
client.prepare("POST", "{{baseUrl}}/setStickerPositionInSet")
.setHeader("content-type", "application/json")
.setBody("{\n \"position\": 0,\n \"sticker\": \"\"\n}")
.execute()
.toCompletableFuture()
.thenAccept(System.out::println)
.join();
client.close();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("{{baseUrl}}/setStickerPositionInSet"))
.header("content-type", "application/json")
.method("POST", HttpRequest.BodyPublishers.ofString("{\n \"position\": 0,\n \"sticker\": \"\"\n}"))
.build();
HttpResponse response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n \"position\": 0,\n \"sticker\": \"\"\n}");
Request request = new Request.Builder()
.url("{{baseUrl}}/setStickerPositionInSet")
.post(body)
.addHeader("content-type", "application/json")
.build();
Response response = client.newCall(request).execute();
HttpResponse response = Unirest.post("{{baseUrl}}/setStickerPositionInSet")
.header("content-type", "application/json")
.body("{\n \"position\": 0,\n \"sticker\": \"\"\n}")
.asString();
const data = JSON.stringify({
position: 0,
sticker: ''
});
const xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener('readystatechange', function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open('POST', '{{baseUrl}}/setStickerPositionInSet');
xhr.setRequestHeader('content-type', 'application/json');
xhr.send(data);
import axios from 'axios';
const options = {
method: 'POST',
url: '{{baseUrl}}/setStickerPositionInSet',
headers: {'content-type': 'application/json'},
data: {position: 0, sticker: ''}
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const url = '{{baseUrl}}/setStickerPositionInSet';
const options = {
method: 'POST',
headers: {'content-type': 'application/json'},
body: '{"position":0,"sticker":""}'
};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
const settings = {
async: true,
crossDomain: true,
url: '{{baseUrl}}/setStickerPositionInSet',
method: 'POST',
headers: {
'content-type': 'application/json'
},
processData: false,
data: '{\n "position": 0,\n "sticker": ""\n}'
};
$.ajax(settings).done(function (response) {
console.log(response);
});
val client = OkHttpClient()
val mediaType = MediaType.parse("application/json")
val body = RequestBody.create(mediaType, "{\n \"position\": 0,\n \"sticker\": \"\"\n}")
val request = Request.Builder()
.url("{{baseUrl}}/setStickerPositionInSet")
.post(body)
.addHeader("content-type", "application/json")
.build()
val response = client.newCall(request).execute()
const http = require('https');
const options = {
method: 'POST',
hostname: 'example.com',
port: null,
path: '/baseUrl/setStickerPositionInSet',
headers: {
'content-type': 'application/json'
}
};
const req = http.request(options, function (res) {
const chunks = [];
res.on('data', function (chunk) {
chunks.push(chunk);
});
res.on('end', function () {
const body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.write(JSON.stringify({position: 0, sticker: ''}));
req.end();
const request = require('request');
const options = {
method: 'POST',
url: '{{baseUrl}}/setStickerPositionInSet',
headers: {'content-type': 'application/json'},
body: {position: 0, sticker: ''},
json: true
};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
const unirest = require('unirest');
const req = unirest('POST', '{{baseUrl}}/setStickerPositionInSet');
req.headers({
'content-type': 'application/json'
});
req.type('json');
req.send({
position: 0,
sticker: ''
});
req.end(function (res) {
if (res.error) throw new Error(res.error);
console.log(res.body);
});
const axios = require('axios').default;
const options = {
method: 'POST',
url: '{{baseUrl}}/setStickerPositionInSet',
headers: {'content-type': 'application/json'},
data: {position: 0, sticker: ''}
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const fetch = require('node-fetch');
const url = '{{baseUrl}}/setStickerPositionInSet';
const options = {
method: 'POST',
headers: {'content-type': 'application/json'},
body: '{"position":0,"sticker":""}'
};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
#import
NSDictionary *headers = @{ @"content-type": @"application/json" };
NSDictionary *parameters = @{ @"position": @0,
@"sticker": @"" };
NSData *postData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"{{baseUrl}}/setStickerPositionInSet"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
[request setHTTPMethod:@"POST"];
[request setAllHTTPHeaderFields:headers];
[request setHTTPBody:postData];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSLog(@"%@", httpResponse);
}
}];
[dataTask resume];
open Cohttp_lwt_unix
open Cohttp
open Lwt
let uri = Uri.of_string "{{baseUrl}}/setStickerPositionInSet" in
let headers = Header.add (Header.init ()) "content-type" "application/json" in
let body = Cohttp_lwt_body.of_string "{\n \"position\": 0,\n \"sticker\": \"\"\n}" in
Client.call ~headers ~body `POST uri
>>= fun (res, body_stream) ->
(* Do stuff with the result *)
"{{baseUrl}}/setStickerPositionInSet",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'position' => 0,
'sticker' => ''
]),
CURLOPT_HTTPHEADER => [
"content-type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
request('POST', '{{baseUrl}}/setStickerPositionInSet', [
'body' => '{
"position": 0,
"sticker": ""
}',
'headers' => [
'content-type' => 'application/json',
],
]);
echo $response->getBody();
setUrl('{{baseUrl}}/setStickerPositionInSet');
$request->setMethod(HTTP_METH_POST);
$request->setHeaders([
'content-type' => 'application/json'
]);
$request->setContentType('application/json');
$request->setBody(json_encode([
'position' => 0,
'sticker' => ''
]));
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
append(json_encode([
'position' => 0,
'sticker' => ''
]));
$request->setRequestUrl('{{baseUrl}}/setStickerPositionInSet');
$request->setRequestMethod('POST');
$request->setBody($body);
$request->setHeaders([
'content-type' => 'application/json'
]);
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
$headers=@{}
$headers.Add("content-type", "application/json")
$response = Invoke-WebRequest -Uri '{{baseUrl}}/setStickerPositionInSet' -Method POST -Headers $headers -ContentType 'application/json' -Body '{
"position": 0,
"sticker": ""
}'
$headers=@{}
$headers.Add("content-type", "application/json")
$response = Invoke-RestMethod -Uri '{{baseUrl}}/setStickerPositionInSet' -Method POST -Headers $headers -ContentType 'application/json' -Body '{
"position": 0,
"sticker": ""
}'
import http.client
conn = http.client.HTTPSConnection("example.com")
payload = "{\n \"position\": 0,\n \"sticker\": \"\"\n}"
headers = { 'content-type': "application/json" }
conn.request("POST", "/baseUrl/setStickerPositionInSet", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
import requests
url = "{{baseUrl}}/setStickerPositionInSet"
payload = {
"position": 0,
"sticker": ""
}
headers = {"content-type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
library(httr)
url <- "{{baseUrl}}/setStickerPositionInSet"
payload <- "{\n \"position\": 0,\n \"sticker\": \"\"\n}"
encode <- "json"
response <- VERB("POST", url, body = payload, content_type("application/json"), encode = encode)
content(response, "text")
require 'uri'
require 'net/http'
url = URI("{{baseUrl}}/setStickerPositionInSet")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["content-type"] = 'application/json'
request.body = "{\n \"position\": 0,\n \"sticker\": \"\"\n}"
response = http.request(request)
puts response.read_body
require 'faraday'
conn = Faraday.new(
url: 'https://example.com',
headers: {'Content-Type' => 'application/json'}
)
response = conn.post('/baseUrl/setStickerPositionInSet') do |req|
req.body = "{\n \"position\": 0,\n \"sticker\": \"\"\n}"
end
puts response.status
puts response.body
use serde_json::json;
use reqwest;
#[tokio::main]
pub async fn main() {
let url = "{{baseUrl}}/setStickerPositionInSet";
let payload = json!({
"position": 0,
"sticker": ""
});
let mut headers = reqwest::header::HeaderMap::new();
headers.insert("content-type", "application/json".parse().unwrap());
let client = reqwest::Client::new();
let response = client.post(url)
.headers(headers)
.json(&payload)
.send()
.await;
let results = response.unwrap()
.json::()
.await
.unwrap();
dbg!(results);
}
curl --request POST \
--url {{baseUrl}}/setStickerPositionInSet \
--header 'content-type: application/json' \
--data '{
"position": 0,
"sticker": ""
}'
echo '{
"position": 0,
"sticker": ""
}' | \
http POST {{baseUrl}}/setStickerPositionInSet \
content-type:application/json
wget --quiet \
--method POST \
--header 'content-type: application/json' \
--body-data '{\n "position": 0,\n "sticker": ""\n}' \
--output-document \
- {{baseUrl}}/setStickerPositionInSet
import Foundation
let headers = ["content-type": "application/json"]
let parameters = [
"position": 0,
"sticker": ""
] as [String : Any]
let postData = JSONSerialization.data(withJSONObject: parameters, options: [])
let request = NSMutableURLRequest(url: NSURL(string: "{{baseUrl}}/setStickerPositionInSet")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error as Any)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
POST
Use this method to receive incoming updates using long polling ([wiki](https---en.wikipedia.org-wiki-Push_technology#Long_polling)). An Array of [Update](https---core.telegram.org-bots-api-#update) objects is returned.
{{baseUrl}}/getUpdates
BODY json
{
"allowed_updates": [],
"limit": 0,
"offset": 0,
"timeout": 0
}
Examples
REQUEST
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(hnd, CURLOPT_URL, "{{baseUrl}}/getUpdates");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "content-type: application/json");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "{\n \"allowed_updates\": [],\n \"limit\": 0,\n \"offset\": 0,\n \"timeout\": 0\n}");
CURLcode ret = curl_easy_perform(hnd);
(require '[clj-http.client :as client])
(client/post "{{baseUrl}}/getUpdates" {:content-type :json
:form-params {:allowed_updates []
:limit 0
:offset 0
:timeout 0}})
require "http/client"
url = "{{baseUrl}}/getUpdates"
headers = HTTP::Headers{
"content-type" => "application/json"
}
reqBody = "{\n \"allowed_updates\": [],\n \"limit\": 0,\n \"offset\": 0,\n \"timeout\": 0\n}"
response = HTTP::Client.post url, headers: headers, body: reqBody
puts response.body
using System.Net.Http.Headers;
var client = new HttpClient();
var request = new HttpRequestMessage
{
Method = HttpMethod.Post,
RequestUri = new Uri("{{baseUrl}}/getUpdates"),
Content = new StringContent("{\n \"allowed_updates\": [],\n \"limit\": 0,\n \"offset\": 0,\n \"timeout\": 0\n}")
{
Headers =
{
ContentType = new MediaTypeHeaderValue("application/json")
}
}
};
using (var response = await client.SendAsync(request))
{
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
}
var client = new RestClient("{{baseUrl}}/getUpdates");
var request = new RestRequest("", Method.Post);
request.AddHeader("content-type", "application/json");
request.AddParameter("application/json", "{\n \"allowed_updates\": [],\n \"limit\": 0,\n \"offset\": 0,\n \"timeout\": 0\n}", ParameterType.RequestBody);
var response = client.Execute(request);
package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "{{baseUrl}}/getUpdates"
payload := strings.NewReader("{\n \"allowed_updates\": [],\n \"limit\": 0,\n \"offset\": 0,\n \"timeout\": 0\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("content-type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
POST /baseUrl/getUpdates HTTP/1.1
Content-Type: application/json
Host: example.com
Content-Length: 72
{
"allowed_updates": [],
"limit": 0,
"offset": 0,
"timeout": 0
}
AsyncHttpClient client = new DefaultAsyncHttpClient();
client.prepare("POST", "{{baseUrl}}/getUpdates")
.setHeader("content-type", "application/json")
.setBody("{\n \"allowed_updates\": [],\n \"limit\": 0,\n \"offset\": 0,\n \"timeout\": 0\n}")
.execute()
.toCompletableFuture()
.thenAccept(System.out::println)
.join();
client.close();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("{{baseUrl}}/getUpdates"))
.header("content-type", "application/json")
.method("POST", HttpRequest.BodyPublishers.ofString("{\n \"allowed_updates\": [],\n \"limit\": 0,\n \"offset\": 0,\n \"timeout\": 0\n}"))
.build();
HttpResponse response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n \"allowed_updates\": [],\n \"limit\": 0,\n \"offset\": 0,\n \"timeout\": 0\n}");
Request request = new Request.Builder()
.url("{{baseUrl}}/getUpdates")
.post(body)
.addHeader("content-type", "application/json")
.build();
Response response = client.newCall(request).execute();
HttpResponse response = Unirest.post("{{baseUrl}}/getUpdates")
.header("content-type", "application/json")
.body("{\n \"allowed_updates\": [],\n \"limit\": 0,\n \"offset\": 0,\n \"timeout\": 0\n}")
.asString();
const data = JSON.stringify({
allowed_updates: [],
limit: 0,
offset: 0,
timeout: 0
});
const xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener('readystatechange', function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open('POST', '{{baseUrl}}/getUpdates');
xhr.setRequestHeader('content-type', 'application/json');
xhr.send(data);
import axios from 'axios';
const options = {
method: 'POST',
url: '{{baseUrl}}/getUpdates',
headers: {'content-type': 'application/json'},
data: {allowed_updates: [], limit: 0, offset: 0, timeout: 0}
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const url = '{{baseUrl}}/getUpdates';
const options = {
method: 'POST',
headers: {'content-type': 'application/json'},
body: '{"allowed_updates":[],"limit":0,"offset":0,"timeout":0}'
};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
const settings = {
async: true,
crossDomain: true,
url: '{{baseUrl}}/getUpdates',
method: 'POST',
headers: {
'content-type': 'application/json'
},
processData: false,
data: '{\n "allowed_updates": [],\n "limit": 0,\n "offset": 0,\n "timeout": 0\n}'
};
$.ajax(settings).done(function (response) {
console.log(response);
});
val client = OkHttpClient()
val mediaType = MediaType.parse("application/json")
val body = RequestBody.create(mediaType, "{\n \"allowed_updates\": [],\n \"limit\": 0,\n \"offset\": 0,\n \"timeout\": 0\n}")
val request = Request.Builder()
.url("{{baseUrl}}/getUpdates")
.post(body)
.addHeader("content-type", "application/json")
.build()
val response = client.newCall(request).execute()
const http = require('https');
const options = {
method: 'POST',
hostname: 'example.com',
port: null,
path: '/baseUrl/getUpdates',
headers: {
'content-type': 'application/json'
}
};
const req = http.request(options, function (res) {
const chunks = [];
res.on('data', function (chunk) {
chunks.push(chunk);
});
res.on('end', function () {
const body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.write(JSON.stringify({allowed_updates: [], limit: 0, offset: 0, timeout: 0}));
req.end();
const request = require('request');
const options = {
method: 'POST',
url: '{{baseUrl}}/getUpdates',
headers: {'content-type': 'application/json'},
body: {allowed_updates: [], limit: 0, offset: 0, timeout: 0},
json: true
};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
const unirest = require('unirest');
const req = unirest('POST', '{{baseUrl}}/getUpdates');
req.headers({
'content-type': 'application/json'
});
req.type('json');
req.send({
allowed_updates: [],
limit: 0,
offset: 0,
timeout: 0
});
req.end(function (res) {
if (res.error) throw new Error(res.error);
console.log(res.body);
});
const axios = require('axios').default;
const options = {
method: 'POST',
url: '{{baseUrl}}/getUpdates',
headers: {'content-type': 'application/json'},
data: {allowed_updates: [], limit: 0, offset: 0, timeout: 0}
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const fetch = require('node-fetch');
const url = '{{baseUrl}}/getUpdates';
const options = {
method: 'POST',
headers: {'content-type': 'application/json'},
body: '{"allowed_updates":[],"limit":0,"offset":0,"timeout":0}'
};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
#import
NSDictionary *headers = @{ @"content-type": @"application/json" };
NSDictionary *parameters = @{ @"allowed_updates": @[ ],
@"limit": @0,
@"offset": @0,
@"timeout": @0 };
NSData *postData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"{{baseUrl}}/getUpdates"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
[request setHTTPMethod:@"POST"];
[request setAllHTTPHeaderFields:headers];
[request setHTTPBody:postData];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSLog(@"%@", httpResponse);
}
}];
[dataTask resume];
open Cohttp_lwt_unix
open Cohttp
open Lwt
let uri = Uri.of_string "{{baseUrl}}/getUpdates" in
let headers = Header.add (Header.init ()) "content-type" "application/json" in
let body = Cohttp_lwt_body.of_string "{\n \"allowed_updates\": [],\n \"limit\": 0,\n \"offset\": 0,\n \"timeout\": 0\n}" in
Client.call ~headers ~body `POST uri
>>= fun (res, body_stream) ->
(* Do stuff with the result *)
"{{baseUrl}}/getUpdates",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'allowed_updates' => [
],
'limit' => 0,
'offset' => 0,
'timeout' => 0
]),
CURLOPT_HTTPHEADER => [
"content-type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
request('POST', '{{baseUrl}}/getUpdates', [
'body' => '{
"allowed_updates": [],
"limit": 0,
"offset": 0,
"timeout": 0
}',
'headers' => [
'content-type' => 'application/json',
],
]);
echo $response->getBody();
setUrl('{{baseUrl}}/getUpdates');
$request->setMethod(HTTP_METH_POST);
$request->setHeaders([
'content-type' => 'application/json'
]);
$request->setContentType('application/json');
$request->setBody(json_encode([
'allowed_updates' => [
],
'limit' => 0,
'offset' => 0,
'timeout' => 0
]));
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
append(json_encode([
'allowed_updates' => [
],
'limit' => 0,
'offset' => 0,
'timeout' => 0
]));
$request->setRequestUrl('{{baseUrl}}/getUpdates');
$request->setRequestMethod('POST');
$request->setBody($body);
$request->setHeaders([
'content-type' => 'application/json'
]);
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
$headers=@{}
$headers.Add("content-type", "application/json")
$response = Invoke-WebRequest -Uri '{{baseUrl}}/getUpdates' -Method POST -Headers $headers -ContentType 'application/json' -Body '{
"allowed_updates": [],
"limit": 0,
"offset": 0,
"timeout": 0
}'
$headers=@{}
$headers.Add("content-type", "application/json")
$response = Invoke-RestMethod -Uri '{{baseUrl}}/getUpdates' -Method POST -Headers $headers -ContentType 'application/json' -Body '{
"allowed_updates": [],
"limit": 0,
"offset": 0,
"timeout": 0
}'
import http.client
conn = http.client.HTTPSConnection("example.com")
payload = "{\n \"allowed_updates\": [],\n \"limit\": 0,\n \"offset\": 0,\n \"timeout\": 0\n}"
headers = { 'content-type': "application/json" }
conn.request("POST", "/baseUrl/getUpdates", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
import requests
url = "{{baseUrl}}/getUpdates"
payload = {
"allowed_updates": [],
"limit": 0,
"offset": 0,
"timeout": 0
}
headers = {"content-type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
library(httr)
url <- "{{baseUrl}}/getUpdates"
payload <- "{\n \"allowed_updates\": [],\n \"limit\": 0,\n \"offset\": 0,\n \"timeout\": 0\n}"
encode <- "json"
response <- VERB("POST", url, body = payload, content_type("application/json"), encode = encode)
content(response, "text")
require 'uri'
require 'net/http'
url = URI("{{baseUrl}}/getUpdates")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["content-type"] = 'application/json'
request.body = "{\n \"allowed_updates\": [],\n \"limit\": 0,\n \"offset\": 0,\n \"timeout\": 0\n}"
response = http.request(request)
puts response.read_body
require 'faraday'
conn = Faraday.new(
url: 'https://example.com',
headers: {'Content-Type' => 'application/json'}
)
response = conn.post('/baseUrl/getUpdates') do |req|
req.body = "{\n \"allowed_updates\": [],\n \"limit\": 0,\n \"offset\": 0,\n \"timeout\": 0\n}"
end
puts response.status
puts response.body
use serde_json::json;
use reqwest;
#[tokio::main]
pub async fn main() {
let url = "{{baseUrl}}/getUpdates";
let payload = json!({
"allowed_updates": (),
"limit": 0,
"offset": 0,
"timeout": 0
});
let mut headers = reqwest::header::HeaderMap::new();
headers.insert("content-type", "application/json".parse().unwrap());
let client = reqwest::Client::new();
let response = client.post(url)
.headers(headers)
.json(&payload)
.send()
.await;
let results = response.unwrap()
.json::()
.await
.unwrap();
dbg!(results);
}
curl --request POST \
--url {{baseUrl}}/getUpdates \
--header 'content-type: application/json' \
--data '{
"allowed_updates": [],
"limit": 0,
"offset": 0,
"timeout": 0
}'
echo '{
"allowed_updates": [],
"limit": 0,
"offset": 0,
"timeout": 0
}' | \
http POST {{baseUrl}}/getUpdates \
content-type:application/json
wget --quiet \
--method POST \
--header 'content-type: application/json' \
--body-data '{\n "allowed_updates": [],\n "limit": 0,\n "offset": 0,\n "timeout": 0\n}' \
--output-document \
- {{baseUrl}}/getUpdates
import Foundation
let headers = ["content-type": "application/json"]
let parameters = [
"allowed_updates": [],
"limit": 0,
"offset": 0,
"timeout": 0
] as [String : Any]
let postData = JSONSerialization.data(withJSONObject: parameters, options: [])
let request = NSMutableURLRequest(url: NSURL(string: "{{baseUrl}}/getUpdates")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error as Any)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
POST
Use this method to remove webhook integration if you decide to switch back to [getUpdates](https---core.telegram.org-bots-api-#getupdates). Returns -True- on success.
{{baseUrl}}/deleteWebhook
BODY json
{
"drop_pending_updates": false
}
Examples
REQUEST
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(hnd, CURLOPT_URL, "{{baseUrl}}/deleteWebhook");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "content-type: application/json");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "{\n \"drop_pending_updates\": false\n}");
CURLcode ret = curl_easy_perform(hnd);
(require '[clj-http.client :as client])
(client/post "{{baseUrl}}/deleteWebhook" {:content-type :json
:form-params {:drop_pending_updates false}})
require "http/client"
url = "{{baseUrl}}/deleteWebhook"
headers = HTTP::Headers{
"content-type" => "application/json"
}
reqBody = "{\n \"drop_pending_updates\": false\n}"
response = HTTP::Client.post url, headers: headers, body: reqBody
puts response.body
using System.Net.Http.Headers;
var client = new HttpClient();
var request = new HttpRequestMessage
{
Method = HttpMethod.Post,
RequestUri = new Uri("{{baseUrl}}/deleteWebhook"),
Content = new StringContent("{\n \"drop_pending_updates\": false\n}")
{
Headers =
{
ContentType = new MediaTypeHeaderValue("application/json")
}
}
};
using (var response = await client.SendAsync(request))
{
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
}
var client = new RestClient("{{baseUrl}}/deleteWebhook");
var request = new RestRequest("", Method.Post);
request.AddHeader("content-type", "application/json");
request.AddParameter("application/json", "{\n \"drop_pending_updates\": false\n}", ParameterType.RequestBody);
var response = client.Execute(request);
package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "{{baseUrl}}/deleteWebhook"
payload := strings.NewReader("{\n \"drop_pending_updates\": false\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("content-type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
POST /baseUrl/deleteWebhook HTTP/1.1
Content-Type: application/json
Host: example.com
Content-Length: 35
{
"drop_pending_updates": false
}
AsyncHttpClient client = new DefaultAsyncHttpClient();
client.prepare("POST", "{{baseUrl}}/deleteWebhook")
.setHeader("content-type", "application/json")
.setBody("{\n \"drop_pending_updates\": false\n}")
.execute()
.toCompletableFuture()
.thenAccept(System.out::println)
.join();
client.close();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("{{baseUrl}}/deleteWebhook"))
.header("content-type", "application/json")
.method("POST", HttpRequest.BodyPublishers.ofString("{\n \"drop_pending_updates\": false\n}"))
.build();
HttpResponse response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n \"drop_pending_updates\": false\n}");
Request request = new Request.Builder()
.url("{{baseUrl}}/deleteWebhook")
.post(body)
.addHeader("content-type", "application/json")
.build();
Response response = client.newCall(request).execute();
HttpResponse response = Unirest.post("{{baseUrl}}/deleteWebhook")
.header("content-type", "application/json")
.body("{\n \"drop_pending_updates\": false\n}")
.asString();
const data = JSON.stringify({
drop_pending_updates: false
});
const xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener('readystatechange', function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open('POST', '{{baseUrl}}/deleteWebhook');
xhr.setRequestHeader('content-type', 'application/json');
xhr.send(data);
import axios from 'axios';
const options = {
method: 'POST',
url: '{{baseUrl}}/deleteWebhook',
headers: {'content-type': 'application/json'},
data: {drop_pending_updates: false}
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const url = '{{baseUrl}}/deleteWebhook';
const options = {
method: 'POST',
headers: {'content-type': 'application/json'},
body: '{"drop_pending_updates":false}'
};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
const settings = {
async: true,
crossDomain: true,
url: '{{baseUrl}}/deleteWebhook',
method: 'POST',
headers: {
'content-type': 'application/json'
},
processData: false,
data: '{\n "drop_pending_updates": false\n}'
};
$.ajax(settings).done(function (response) {
console.log(response);
});
val client = OkHttpClient()
val mediaType = MediaType.parse("application/json")
val body = RequestBody.create(mediaType, "{\n \"drop_pending_updates\": false\n}")
val request = Request.Builder()
.url("{{baseUrl}}/deleteWebhook")
.post(body)
.addHeader("content-type", "application/json")
.build()
val response = client.newCall(request).execute()
const http = require('https');
const options = {
method: 'POST',
hostname: 'example.com',
port: null,
path: '/baseUrl/deleteWebhook',
headers: {
'content-type': 'application/json'
}
};
const req = http.request(options, function (res) {
const chunks = [];
res.on('data', function (chunk) {
chunks.push(chunk);
});
res.on('end', function () {
const body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.write(JSON.stringify({drop_pending_updates: false}));
req.end();
const request = require('request');
const options = {
method: 'POST',
url: '{{baseUrl}}/deleteWebhook',
headers: {'content-type': 'application/json'},
body: {drop_pending_updates: false},
json: true
};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
const unirest = require('unirest');
const req = unirest('POST', '{{baseUrl}}/deleteWebhook');
req.headers({
'content-type': 'application/json'
});
req.type('json');
req.send({
drop_pending_updates: false
});
req.end(function (res) {
if (res.error) throw new Error(res.error);
console.log(res.body);
});
const axios = require('axios').default;
const options = {
method: 'POST',
url: '{{baseUrl}}/deleteWebhook',
headers: {'content-type': 'application/json'},
data: {drop_pending_updates: false}
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const fetch = require('node-fetch');
const url = '{{baseUrl}}/deleteWebhook';
const options = {
method: 'POST',
headers: {'content-type': 'application/json'},
body: '{"drop_pending_updates":false}'
};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
#import
NSDictionary *headers = @{ @"content-type": @"application/json" };
NSDictionary *parameters = @{ @"drop_pending_updates": @NO };
NSData *postData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"{{baseUrl}}/deleteWebhook"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
[request setHTTPMethod:@"POST"];
[request setAllHTTPHeaderFields:headers];
[request setHTTPBody:postData];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSLog(@"%@", httpResponse);
}
}];
[dataTask resume];
open Cohttp_lwt_unix
open Cohttp
open Lwt
let uri = Uri.of_string "{{baseUrl}}/deleteWebhook" in
let headers = Header.add (Header.init ()) "content-type" "application/json" in
let body = Cohttp_lwt_body.of_string "{\n \"drop_pending_updates\": false\n}" in
Client.call ~headers ~body `POST uri
>>= fun (res, body_stream) ->
(* Do stuff with the result *)
"{{baseUrl}}/deleteWebhook",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'drop_pending_updates' => null
]),
CURLOPT_HTTPHEADER => [
"content-type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
request('POST', '{{baseUrl}}/deleteWebhook', [
'body' => '{
"drop_pending_updates": false
}',
'headers' => [
'content-type' => 'application/json',
],
]);
echo $response->getBody();
setUrl('{{baseUrl}}/deleteWebhook');
$request->setMethod(HTTP_METH_POST);
$request->setHeaders([
'content-type' => 'application/json'
]);
$request->setContentType('application/json');
$request->setBody(json_encode([
'drop_pending_updates' => null
]));
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
append(json_encode([
'drop_pending_updates' => null
]));
$request->setRequestUrl('{{baseUrl}}/deleteWebhook');
$request->setRequestMethod('POST');
$request->setBody($body);
$request->setHeaders([
'content-type' => 'application/json'
]);
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
$headers=@{}
$headers.Add("content-type", "application/json")
$response = Invoke-WebRequest -Uri '{{baseUrl}}/deleteWebhook' -Method POST -Headers $headers -ContentType 'application/json' -Body '{
"drop_pending_updates": false
}'
$headers=@{}
$headers.Add("content-type", "application/json")
$response = Invoke-RestMethod -Uri '{{baseUrl}}/deleteWebhook' -Method POST -Headers $headers -ContentType 'application/json' -Body '{
"drop_pending_updates": false
}'
import http.client
conn = http.client.HTTPSConnection("example.com")
payload = "{\n \"drop_pending_updates\": false\n}"
headers = { 'content-type': "application/json" }
conn.request("POST", "/baseUrl/deleteWebhook", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
import requests
url = "{{baseUrl}}/deleteWebhook"
payload = { "drop_pending_updates": False }
headers = {"content-type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
library(httr)
url <- "{{baseUrl}}/deleteWebhook"
payload <- "{\n \"drop_pending_updates\": false\n}"
encode <- "json"
response <- VERB("POST", url, body = payload, content_type("application/json"), encode = encode)
content(response, "text")
require 'uri'
require 'net/http'
url = URI("{{baseUrl}}/deleteWebhook")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["content-type"] = 'application/json'
request.body = "{\n \"drop_pending_updates\": false\n}"
response = http.request(request)
puts response.read_body
require 'faraday'
conn = Faraday.new(
url: 'https://example.com',
headers: {'Content-Type' => 'application/json'}
)
response = conn.post('/baseUrl/deleteWebhook') do |req|
req.body = "{\n \"drop_pending_updates\": false\n}"
end
puts response.status
puts response.body
use serde_json::json;
use reqwest;
#[tokio::main]
pub async fn main() {
let url = "{{baseUrl}}/deleteWebhook";
let payload = json!({"drop_pending_updates": false});
let mut headers = reqwest::header::HeaderMap::new();
headers.insert("content-type", "application/json".parse().unwrap());
let client = reqwest::Client::new();
let response = client.post(url)
.headers(headers)
.json(&payload)
.send()
.await;
let results = response.unwrap()
.json::()
.await
.unwrap();
dbg!(results);
}
curl --request POST \
--url {{baseUrl}}/deleteWebhook \
--header 'content-type: application/json' \
--data '{
"drop_pending_updates": false
}'
echo '{
"drop_pending_updates": false
}' | \
http POST {{baseUrl}}/deleteWebhook \
content-type:application/json
wget --quiet \
--method POST \
--header 'content-type: application/json' \
--body-data '{\n "drop_pending_updates": false\n}' \
--output-document \
- {{baseUrl}}/deleteWebhook
import Foundation
let headers = ["content-type": "application/json"]
let parameters = ["drop_pending_updates": false] as [String : Any]
let postData = JSONSerialization.data(withJSONObject: parameters, options: [])
let request = NSMutableURLRequest(url: NSURL(string: "{{baseUrl}}/deleteWebhook")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error as Any)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
POST
Use this method to send a game. On success, the sent [Message](https---core.telegram.org-bots-api-#message) is returned.
{{baseUrl}}/sendGame
BODY json
{
"allow_sending_without_reply": false,
"chat_id": 0,
"disable_notification": false,
"game_short_name": "",
"reply_markup": {
"inline_keyboard": []
},
"reply_to_message_id": 0
}
Examples
REQUEST
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(hnd, CURLOPT_URL, "{{baseUrl}}/sendGame");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "content-type: application/json");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "{\n \"allow_sending_without_reply\": false,\n \"chat_id\": 0,\n \"disable_notification\": false,\n \"game_short_name\": \"\",\n \"reply_markup\": {\n \"inline_keyboard\": []\n },\n \"reply_to_message_id\": 0\n}");
CURLcode ret = curl_easy_perform(hnd);
(require '[clj-http.client :as client])
(client/post "{{baseUrl}}/sendGame" {:content-type :json
:form-params {:allow_sending_without_reply false
:chat_id 0
:disable_notification false
:game_short_name ""
:reply_markup {:inline_keyboard []}
:reply_to_message_id 0}})
require "http/client"
url = "{{baseUrl}}/sendGame"
headers = HTTP::Headers{
"content-type" => "application/json"
}
reqBody = "{\n \"allow_sending_without_reply\": false,\n \"chat_id\": 0,\n \"disable_notification\": false,\n \"game_short_name\": \"\",\n \"reply_markup\": {\n \"inline_keyboard\": []\n },\n \"reply_to_message_id\": 0\n}"
response = HTTP::Client.post url, headers: headers, body: reqBody
puts response.body
using System.Net.Http.Headers;
var client = new HttpClient();
var request = new HttpRequestMessage
{
Method = HttpMethod.Post,
RequestUri = new Uri("{{baseUrl}}/sendGame"),
Content = new StringContent("{\n \"allow_sending_without_reply\": false,\n \"chat_id\": 0,\n \"disable_notification\": false,\n \"game_short_name\": \"\",\n \"reply_markup\": {\n \"inline_keyboard\": []\n },\n \"reply_to_message_id\": 0\n}")
{
Headers =
{
ContentType = new MediaTypeHeaderValue("application/json")
}
}
};
using (var response = await client.SendAsync(request))
{
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
}
var client = new RestClient("{{baseUrl}}/sendGame");
var request = new RestRequest("", Method.Post);
request.AddHeader("content-type", "application/json");
request.AddParameter("application/json", "{\n \"allow_sending_without_reply\": false,\n \"chat_id\": 0,\n \"disable_notification\": false,\n \"game_short_name\": \"\",\n \"reply_markup\": {\n \"inline_keyboard\": []\n },\n \"reply_to_message_id\": 0\n}", ParameterType.RequestBody);
var response = client.Execute(request);
package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "{{baseUrl}}/sendGame"
payload := strings.NewReader("{\n \"allow_sending_without_reply\": false,\n \"chat_id\": 0,\n \"disable_notification\": false,\n \"game_short_name\": \"\",\n \"reply_markup\": {\n \"inline_keyboard\": []\n },\n \"reply_to_message_id\": 0\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("content-type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
POST /baseUrl/sendGame HTTP/1.1
Content-Type: application/json
Host: example.com
Content-Length: 195
{
"allow_sending_without_reply": false,
"chat_id": 0,
"disable_notification": false,
"game_short_name": "",
"reply_markup": {
"inline_keyboard": []
},
"reply_to_message_id": 0
}
AsyncHttpClient client = new DefaultAsyncHttpClient();
client.prepare("POST", "{{baseUrl}}/sendGame")
.setHeader("content-type", "application/json")
.setBody("{\n \"allow_sending_without_reply\": false,\n \"chat_id\": 0,\n \"disable_notification\": false,\n \"game_short_name\": \"\",\n \"reply_markup\": {\n \"inline_keyboard\": []\n },\n \"reply_to_message_id\": 0\n}")
.execute()
.toCompletableFuture()
.thenAccept(System.out::println)
.join();
client.close();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("{{baseUrl}}/sendGame"))
.header("content-type", "application/json")
.method("POST", HttpRequest.BodyPublishers.ofString("{\n \"allow_sending_without_reply\": false,\n \"chat_id\": 0,\n \"disable_notification\": false,\n \"game_short_name\": \"\",\n \"reply_markup\": {\n \"inline_keyboard\": []\n },\n \"reply_to_message_id\": 0\n}"))
.build();
HttpResponse response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n \"allow_sending_without_reply\": false,\n \"chat_id\": 0,\n \"disable_notification\": false,\n \"game_short_name\": \"\",\n \"reply_markup\": {\n \"inline_keyboard\": []\n },\n \"reply_to_message_id\": 0\n}");
Request request = new Request.Builder()
.url("{{baseUrl}}/sendGame")
.post(body)
.addHeader("content-type", "application/json")
.build();
Response response = client.newCall(request).execute();
HttpResponse response = Unirest.post("{{baseUrl}}/sendGame")
.header("content-type", "application/json")
.body("{\n \"allow_sending_without_reply\": false,\n \"chat_id\": 0,\n \"disable_notification\": false,\n \"game_short_name\": \"\",\n \"reply_markup\": {\n \"inline_keyboard\": []\n },\n \"reply_to_message_id\": 0\n}")
.asString();
const data = JSON.stringify({
allow_sending_without_reply: false,
chat_id: 0,
disable_notification: false,
game_short_name: '',
reply_markup: {
inline_keyboard: []
},
reply_to_message_id: 0
});
const xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener('readystatechange', function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open('POST', '{{baseUrl}}/sendGame');
xhr.setRequestHeader('content-type', 'application/json');
xhr.send(data);
import axios from 'axios';
const options = {
method: 'POST',
url: '{{baseUrl}}/sendGame',
headers: {'content-type': 'application/json'},
data: {
allow_sending_without_reply: false,
chat_id: 0,
disable_notification: false,
game_short_name: '',
reply_markup: {inline_keyboard: []},
reply_to_message_id: 0
}
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const url = '{{baseUrl}}/sendGame';
const options = {
method: 'POST',
headers: {'content-type': 'application/json'},
body: '{"allow_sending_without_reply":false,"chat_id":0,"disable_notification":false,"game_short_name":"","reply_markup":{"inline_keyboard":[]},"reply_to_message_id":0}'
};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
const settings = {
async: true,
crossDomain: true,
url: '{{baseUrl}}/sendGame',
method: 'POST',
headers: {
'content-type': 'application/json'
},
processData: false,
data: '{\n "allow_sending_without_reply": false,\n "chat_id": 0,\n "disable_notification": false,\n "game_short_name": "",\n "reply_markup": {\n "inline_keyboard": []\n },\n "reply_to_message_id": 0\n}'
};
$.ajax(settings).done(function (response) {
console.log(response);
});
val client = OkHttpClient()
val mediaType = MediaType.parse("application/json")
val body = RequestBody.create(mediaType, "{\n \"allow_sending_without_reply\": false,\n \"chat_id\": 0,\n \"disable_notification\": false,\n \"game_short_name\": \"\",\n \"reply_markup\": {\n \"inline_keyboard\": []\n },\n \"reply_to_message_id\": 0\n}")
val request = Request.Builder()
.url("{{baseUrl}}/sendGame")
.post(body)
.addHeader("content-type", "application/json")
.build()
val response = client.newCall(request).execute()
const http = require('https');
const options = {
method: 'POST',
hostname: 'example.com',
port: null,
path: '/baseUrl/sendGame',
headers: {
'content-type': 'application/json'
}
};
const req = http.request(options, function (res) {
const chunks = [];
res.on('data', function (chunk) {
chunks.push(chunk);
});
res.on('end', function () {
const body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.write(JSON.stringify({
allow_sending_without_reply: false,
chat_id: 0,
disable_notification: false,
game_short_name: '',
reply_markup: {inline_keyboard: []},
reply_to_message_id: 0
}));
req.end();
const request = require('request');
const options = {
method: 'POST',
url: '{{baseUrl}}/sendGame',
headers: {'content-type': 'application/json'},
body: {
allow_sending_without_reply: false,
chat_id: 0,
disable_notification: false,
game_short_name: '',
reply_markup: {inline_keyboard: []},
reply_to_message_id: 0
},
json: true
};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
const unirest = require('unirest');
const req = unirest('POST', '{{baseUrl}}/sendGame');
req.headers({
'content-type': 'application/json'
});
req.type('json');
req.send({
allow_sending_without_reply: false,
chat_id: 0,
disable_notification: false,
game_short_name: '',
reply_markup: {
inline_keyboard: []
},
reply_to_message_id: 0
});
req.end(function (res) {
if (res.error) throw new Error(res.error);
console.log(res.body);
});
const axios = require('axios').default;
const options = {
method: 'POST',
url: '{{baseUrl}}/sendGame',
headers: {'content-type': 'application/json'},
data: {
allow_sending_without_reply: false,
chat_id: 0,
disable_notification: false,
game_short_name: '',
reply_markup: {inline_keyboard: []},
reply_to_message_id: 0
}
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const fetch = require('node-fetch');
const url = '{{baseUrl}}/sendGame';
const options = {
method: 'POST',
headers: {'content-type': 'application/json'},
body: '{"allow_sending_without_reply":false,"chat_id":0,"disable_notification":false,"game_short_name":"","reply_markup":{"inline_keyboard":[]},"reply_to_message_id":0}'
};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
#import
NSDictionary *headers = @{ @"content-type": @"application/json" };
NSDictionary *parameters = @{ @"allow_sending_without_reply": @NO,
@"chat_id": @0,
@"disable_notification": @NO,
@"game_short_name": @"",
@"reply_markup": @{ @"inline_keyboard": @[ ] },
@"reply_to_message_id": @0 };
NSData *postData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"{{baseUrl}}/sendGame"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
[request setHTTPMethod:@"POST"];
[request setAllHTTPHeaderFields:headers];
[request setHTTPBody:postData];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSLog(@"%@", httpResponse);
}
}];
[dataTask resume];
open Cohttp_lwt_unix
open Cohttp
open Lwt
let uri = Uri.of_string "{{baseUrl}}/sendGame" in
let headers = Header.add (Header.init ()) "content-type" "application/json" in
let body = Cohttp_lwt_body.of_string "{\n \"allow_sending_without_reply\": false,\n \"chat_id\": 0,\n \"disable_notification\": false,\n \"game_short_name\": \"\",\n \"reply_markup\": {\n \"inline_keyboard\": []\n },\n \"reply_to_message_id\": 0\n}" in
Client.call ~headers ~body `POST uri
>>= fun (res, body_stream) ->
(* Do stuff with the result *)
"{{baseUrl}}/sendGame",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'allow_sending_without_reply' => null,
'chat_id' => 0,
'disable_notification' => null,
'game_short_name' => '',
'reply_markup' => [
'inline_keyboard' => [
]
],
'reply_to_message_id' => 0
]),
CURLOPT_HTTPHEADER => [
"content-type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
request('POST', '{{baseUrl}}/sendGame', [
'body' => '{
"allow_sending_without_reply": false,
"chat_id": 0,
"disable_notification": false,
"game_short_name": "",
"reply_markup": {
"inline_keyboard": []
},
"reply_to_message_id": 0
}',
'headers' => [
'content-type' => 'application/json',
],
]);
echo $response->getBody();
setUrl('{{baseUrl}}/sendGame');
$request->setMethod(HTTP_METH_POST);
$request->setHeaders([
'content-type' => 'application/json'
]);
$request->setContentType('application/json');
$request->setBody(json_encode([
'allow_sending_without_reply' => null,
'chat_id' => 0,
'disable_notification' => null,
'game_short_name' => '',
'reply_markup' => [
'inline_keyboard' => [
]
],
'reply_to_message_id' => 0
]));
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
append(json_encode([
'allow_sending_without_reply' => null,
'chat_id' => 0,
'disable_notification' => null,
'game_short_name' => '',
'reply_markup' => [
'inline_keyboard' => [
]
],
'reply_to_message_id' => 0
]));
$request->setRequestUrl('{{baseUrl}}/sendGame');
$request->setRequestMethod('POST');
$request->setBody($body);
$request->setHeaders([
'content-type' => 'application/json'
]);
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
$headers=@{}
$headers.Add("content-type", "application/json")
$response = Invoke-WebRequest -Uri '{{baseUrl}}/sendGame' -Method POST -Headers $headers -ContentType 'application/json' -Body '{
"allow_sending_without_reply": false,
"chat_id": 0,
"disable_notification": false,
"game_short_name": "",
"reply_markup": {
"inline_keyboard": []
},
"reply_to_message_id": 0
}'
$headers=@{}
$headers.Add("content-type", "application/json")
$response = Invoke-RestMethod -Uri '{{baseUrl}}/sendGame' -Method POST -Headers $headers -ContentType 'application/json' -Body '{
"allow_sending_without_reply": false,
"chat_id": 0,
"disable_notification": false,
"game_short_name": "",
"reply_markup": {
"inline_keyboard": []
},
"reply_to_message_id": 0
}'
import http.client
conn = http.client.HTTPSConnection("example.com")
payload = "{\n \"allow_sending_without_reply\": false,\n \"chat_id\": 0,\n \"disable_notification\": false,\n \"game_short_name\": \"\",\n \"reply_markup\": {\n \"inline_keyboard\": []\n },\n \"reply_to_message_id\": 0\n}"
headers = { 'content-type': "application/json" }
conn.request("POST", "/baseUrl/sendGame", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
import requests
url = "{{baseUrl}}/sendGame"
payload = {
"allow_sending_without_reply": False,
"chat_id": 0,
"disable_notification": False,
"game_short_name": "",
"reply_markup": { "inline_keyboard": [] },
"reply_to_message_id": 0
}
headers = {"content-type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
library(httr)
url <- "{{baseUrl}}/sendGame"
payload <- "{\n \"allow_sending_without_reply\": false,\n \"chat_id\": 0,\n \"disable_notification\": false,\n \"game_short_name\": \"\",\n \"reply_markup\": {\n \"inline_keyboard\": []\n },\n \"reply_to_message_id\": 0\n}"
encode <- "json"
response <- VERB("POST", url, body = payload, content_type("application/json"), encode = encode)
content(response, "text")
require 'uri'
require 'net/http'
url = URI("{{baseUrl}}/sendGame")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["content-type"] = 'application/json'
request.body = "{\n \"allow_sending_without_reply\": false,\n \"chat_id\": 0,\n \"disable_notification\": false,\n \"game_short_name\": \"\",\n \"reply_markup\": {\n \"inline_keyboard\": []\n },\n \"reply_to_message_id\": 0\n}"
response = http.request(request)
puts response.read_body
require 'faraday'
conn = Faraday.new(
url: 'https://example.com',
headers: {'Content-Type' => 'application/json'}
)
response = conn.post('/baseUrl/sendGame') do |req|
req.body = "{\n \"allow_sending_without_reply\": false,\n \"chat_id\": 0,\n \"disable_notification\": false,\n \"game_short_name\": \"\",\n \"reply_markup\": {\n \"inline_keyboard\": []\n },\n \"reply_to_message_id\": 0\n}"
end
puts response.status
puts response.body
use serde_json::json;
use reqwest;
#[tokio::main]
pub async fn main() {
let url = "{{baseUrl}}/sendGame";
let payload = json!({
"allow_sending_without_reply": false,
"chat_id": 0,
"disable_notification": false,
"game_short_name": "",
"reply_markup": json!({"inline_keyboard": ()}),
"reply_to_message_id": 0
});
let mut headers = reqwest::header::HeaderMap::new();
headers.insert("content-type", "application/json".parse().unwrap());
let client = reqwest::Client::new();
let response = client.post(url)
.headers(headers)
.json(&payload)
.send()
.await;
let results = response.unwrap()
.json::()
.await
.unwrap();
dbg!(results);
}
curl --request POST \
--url {{baseUrl}}/sendGame \
--header 'content-type: application/json' \
--data '{
"allow_sending_without_reply": false,
"chat_id": 0,
"disable_notification": false,
"game_short_name": "",
"reply_markup": {
"inline_keyboard": []
},
"reply_to_message_id": 0
}'
echo '{
"allow_sending_without_reply": false,
"chat_id": 0,
"disable_notification": false,
"game_short_name": "",
"reply_markup": {
"inline_keyboard": []
},
"reply_to_message_id": 0
}' | \
http POST {{baseUrl}}/sendGame \
content-type:application/json
wget --quiet \
--method POST \
--header 'content-type: application/json' \
--body-data '{\n "allow_sending_without_reply": false,\n "chat_id": 0,\n "disable_notification": false,\n "game_short_name": "",\n "reply_markup": {\n "inline_keyboard": []\n },\n "reply_to_message_id": 0\n}' \
--output-document \
- {{baseUrl}}/sendGame
import Foundation
let headers = ["content-type": "application/json"]
let parameters = [
"allow_sending_without_reply": false,
"chat_id": 0,
"disable_notification": false,
"game_short_name": "",
"reply_markup": ["inline_keyboard": []],
"reply_to_message_id": 0
] as [String : Any]
let postData = JSONSerialization.data(withJSONObject: parameters, options: [])
let request = NSMutableURLRequest(url: NSURL(string: "{{baseUrl}}/sendGame")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error as Any)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
POST
Use this method to send a native poll. On success, the sent [Message](https---core.telegram.org-bots-api-#message) is returned.
{{baseUrl}}/sendPoll
BODY json
{
"allow_sending_without_reply": false,
"allows_multiple_answers": false,
"chat_id": "",
"close_date": 0,
"correct_option_id": 0,
"disable_notification": false,
"explanation": "",
"explanation_entities": [
{
"language": "",
"length": 0,
"offset": 0,
"type": "",
"url": "",
"user": {
"can_join_groups": false,
"can_read_all_group_messages": false,
"first_name": "",
"id": 0,
"is_bot": false,
"language_code": "",
"last_name": "",
"supports_inline_queries": false,
"username": ""
}
}
],
"explanation_parse_mode": "",
"is_anonymous": false,
"is_closed": false,
"open_period": 0,
"options": [],
"question": "",
"reply_markup": "",
"reply_to_message_id": 0,
"type": ""
}
Examples
REQUEST
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(hnd, CURLOPT_URL, "{{baseUrl}}/sendPoll");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "content-type: application/json");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "{\n \"allow_sending_without_reply\": false,\n \"allows_multiple_answers\": false,\n \"chat_id\": \"\",\n \"close_date\": 0,\n \"correct_option_id\": 0,\n \"disable_notification\": false,\n \"explanation\": \"\",\n \"explanation_entities\": [\n {\n \"language\": \"\",\n \"length\": 0,\n \"offset\": 0,\n \"type\": \"\",\n \"url\": \"\",\n \"user\": {\n \"can_join_groups\": false,\n \"can_read_all_group_messages\": false,\n \"first_name\": \"\",\n \"id\": 0,\n \"is_bot\": false,\n \"language_code\": \"\",\n \"last_name\": \"\",\n \"supports_inline_queries\": false,\n \"username\": \"\"\n }\n }\n ],\n \"explanation_parse_mode\": \"\",\n \"is_anonymous\": false,\n \"is_closed\": false,\n \"open_period\": 0,\n \"options\": [],\n \"question\": \"\",\n \"reply_markup\": \"\",\n \"reply_to_message_id\": 0,\n \"type\": \"\"\n}");
CURLcode ret = curl_easy_perform(hnd);
(require '[clj-http.client :as client])
(client/post "{{baseUrl}}/sendPoll" {:content-type :json
:form-params {:allow_sending_without_reply false
:allows_multiple_answers false
:chat_id ""
:close_date 0
:correct_option_id 0
:disable_notification false
:explanation ""
:explanation_entities [{:language ""
:length 0
:offset 0
:type ""
:url ""
:user {:can_join_groups false
:can_read_all_group_messages false
:first_name ""
:id 0
:is_bot false
:language_code ""
:last_name ""
:supports_inline_queries false
:username ""}}]
:explanation_parse_mode ""
:is_anonymous false
:is_closed false
:open_period 0
:options []
:question ""
:reply_markup ""
:reply_to_message_id 0
:type ""}})
require "http/client"
url = "{{baseUrl}}/sendPoll"
headers = HTTP::Headers{
"content-type" => "application/json"
}
reqBody = "{\n \"allow_sending_without_reply\": false,\n \"allows_multiple_answers\": false,\n \"chat_id\": \"\",\n \"close_date\": 0,\n \"correct_option_id\": 0,\n \"disable_notification\": false,\n \"explanation\": \"\",\n \"explanation_entities\": [\n {\n \"language\": \"\",\n \"length\": 0,\n \"offset\": 0,\n \"type\": \"\",\n \"url\": \"\",\n \"user\": {\n \"can_join_groups\": false,\n \"can_read_all_group_messages\": false,\n \"first_name\": \"\",\n \"id\": 0,\n \"is_bot\": false,\n \"language_code\": \"\",\n \"last_name\": \"\",\n \"supports_inline_queries\": false,\n \"username\": \"\"\n }\n }\n ],\n \"explanation_parse_mode\": \"\",\n \"is_anonymous\": false,\n \"is_closed\": false,\n \"open_period\": 0,\n \"options\": [],\n \"question\": \"\",\n \"reply_markup\": \"\",\n \"reply_to_message_id\": 0,\n \"type\": \"\"\n}"
response = HTTP::Client.post url, headers: headers, body: reqBody
puts response.body
using System.Net.Http.Headers;
var client = new HttpClient();
var request = new HttpRequestMessage
{
Method = HttpMethod.Post,
RequestUri = new Uri("{{baseUrl}}/sendPoll"),
Content = new StringContent("{\n \"allow_sending_without_reply\": false,\n \"allows_multiple_answers\": false,\n \"chat_id\": \"\",\n \"close_date\": 0,\n \"correct_option_id\": 0,\n \"disable_notification\": false,\n \"explanation\": \"\",\n \"explanation_entities\": [\n {\n \"language\": \"\",\n \"length\": 0,\n \"offset\": 0,\n \"type\": \"\",\n \"url\": \"\",\n \"user\": {\n \"can_join_groups\": false,\n \"can_read_all_group_messages\": false,\n \"first_name\": \"\",\n \"id\": 0,\n \"is_bot\": false,\n \"language_code\": \"\",\n \"last_name\": \"\",\n \"supports_inline_queries\": false,\n \"username\": \"\"\n }\n }\n ],\n \"explanation_parse_mode\": \"\",\n \"is_anonymous\": false,\n \"is_closed\": false,\n \"open_period\": 0,\n \"options\": [],\n \"question\": \"\",\n \"reply_markup\": \"\",\n \"reply_to_message_id\": 0,\n \"type\": \"\"\n}")
{
Headers =
{
ContentType = new MediaTypeHeaderValue("application/json")
}
}
};
using (var response = await client.SendAsync(request))
{
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
}
var client = new RestClient("{{baseUrl}}/sendPoll");
var request = new RestRequest("", Method.Post);
request.AddHeader("content-type", "application/json");
request.AddParameter("application/json", "{\n \"allow_sending_without_reply\": false,\n \"allows_multiple_answers\": false,\n \"chat_id\": \"\",\n \"close_date\": 0,\n \"correct_option_id\": 0,\n \"disable_notification\": false,\n \"explanation\": \"\",\n \"explanation_entities\": [\n {\n \"language\": \"\",\n \"length\": 0,\n \"offset\": 0,\n \"type\": \"\",\n \"url\": \"\",\n \"user\": {\n \"can_join_groups\": false,\n \"can_read_all_group_messages\": false,\n \"first_name\": \"\",\n \"id\": 0,\n \"is_bot\": false,\n \"language_code\": \"\",\n \"last_name\": \"\",\n \"supports_inline_queries\": false,\n \"username\": \"\"\n }\n }\n ],\n \"explanation_parse_mode\": \"\",\n \"is_anonymous\": false,\n \"is_closed\": false,\n \"open_period\": 0,\n \"options\": [],\n \"question\": \"\",\n \"reply_markup\": \"\",\n \"reply_to_message_id\": 0,\n \"type\": \"\"\n}", ParameterType.RequestBody);
var response = client.Execute(request);
package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "{{baseUrl}}/sendPoll"
payload := strings.NewReader("{\n \"allow_sending_without_reply\": false,\n \"allows_multiple_answers\": false,\n \"chat_id\": \"\",\n \"close_date\": 0,\n \"correct_option_id\": 0,\n \"disable_notification\": false,\n \"explanation\": \"\",\n \"explanation_entities\": [\n {\n \"language\": \"\",\n \"length\": 0,\n \"offset\": 0,\n \"type\": \"\",\n \"url\": \"\",\n \"user\": {\n \"can_join_groups\": false,\n \"can_read_all_group_messages\": false,\n \"first_name\": \"\",\n \"id\": 0,\n \"is_bot\": false,\n \"language_code\": \"\",\n \"last_name\": \"\",\n \"supports_inline_queries\": false,\n \"username\": \"\"\n }\n }\n ],\n \"explanation_parse_mode\": \"\",\n \"is_anonymous\": false,\n \"is_closed\": false,\n \"open_period\": 0,\n \"options\": [],\n \"question\": \"\",\n \"reply_markup\": \"\",\n \"reply_to_message_id\": 0,\n \"type\": \"\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("content-type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
POST /baseUrl/sendPoll HTTP/1.1
Content-Type: application/json
Host: example.com
Content-Length: 823
{
"allow_sending_without_reply": false,
"allows_multiple_answers": false,
"chat_id": "",
"close_date": 0,
"correct_option_id": 0,
"disable_notification": false,
"explanation": "",
"explanation_entities": [
{
"language": "",
"length": 0,
"offset": 0,
"type": "",
"url": "",
"user": {
"can_join_groups": false,
"can_read_all_group_messages": false,
"first_name": "",
"id": 0,
"is_bot": false,
"language_code": "",
"last_name": "",
"supports_inline_queries": false,
"username": ""
}
}
],
"explanation_parse_mode": "",
"is_anonymous": false,
"is_closed": false,
"open_period": 0,
"options": [],
"question": "",
"reply_markup": "",
"reply_to_message_id": 0,
"type": ""
}
AsyncHttpClient client = new DefaultAsyncHttpClient();
client.prepare("POST", "{{baseUrl}}/sendPoll")
.setHeader("content-type", "application/json")
.setBody("{\n \"allow_sending_without_reply\": false,\n \"allows_multiple_answers\": false,\n \"chat_id\": \"\",\n \"close_date\": 0,\n \"correct_option_id\": 0,\n \"disable_notification\": false,\n \"explanation\": \"\",\n \"explanation_entities\": [\n {\n \"language\": \"\",\n \"length\": 0,\n \"offset\": 0,\n \"type\": \"\",\n \"url\": \"\",\n \"user\": {\n \"can_join_groups\": false,\n \"can_read_all_group_messages\": false,\n \"first_name\": \"\",\n \"id\": 0,\n \"is_bot\": false,\n \"language_code\": \"\",\n \"last_name\": \"\",\n \"supports_inline_queries\": false,\n \"username\": \"\"\n }\n }\n ],\n \"explanation_parse_mode\": \"\",\n \"is_anonymous\": false,\n \"is_closed\": false,\n \"open_period\": 0,\n \"options\": [],\n \"question\": \"\",\n \"reply_markup\": \"\",\n \"reply_to_message_id\": 0,\n \"type\": \"\"\n}")
.execute()
.toCompletableFuture()
.thenAccept(System.out::println)
.join();
client.close();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("{{baseUrl}}/sendPoll"))
.header("content-type", "application/json")
.method("POST", HttpRequest.BodyPublishers.ofString("{\n \"allow_sending_without_reply\": false,\n \"allows_multiple_answers\": false,\n \"chat_id\": \"\",\n \"close_date\": 0,\n \"correct_option_id\": 0,\n \"disable_notification\": false,\n \"explanation\": \"\",\n \"explanation_entities\": [\n {\n \"language\": \"\",\n \"length\": 0,\n \"offset\": 0,\n \"type\": \"\",\n \"url\": \"\",\n \"user\": {\n \"can_join_groups\": false,\n \"can_read_all_group_messages\": false,\n \"first_name\": \"\",\n \"id\": 0,\n \"is_bot\": false,\n \"language_code\": \"\",\n \"last_name\": \"\",\n \"supports_inline_queries\": false,\n \"username\": \"\"\n }\n }\n ],\n \"explanation_parse_mode\": \"\",\n \"is_anonymous\": false,\n \"is_closed\": false,\n \"open_period\": 0,\n \"options\": [],\n \"question\": \"\",\n \"reply_markup\": \"\",\n \"reply_to_message_id\": 0,\n \"type\": \"\"\n}"))
.build();
HttpResponse response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n \"allow_sending_without_reply\": false,\n \"allows_multiple_answers\": false,\n \"chat_id\": \"\",\n \"close_date\": 0,\n \"correct_option_id\": 0,\n \"disable_notification\": false,\n \"explanation\": \"\",\n \"explanation_entities\": [\n {\n \"language\": \"\",\n \"length\": 0,\n \"offset\": 0,\n \"type\": \"\",\n \"url\": \"\",\n \"user\": {\n \"can_join_groups\": false,\n \"can_read_all_group_messages\": false,\n \"first_name\": \"\",\n \"id\": 0,\n \"is_bot\": false,\n \"language_code\": \"\",\n \"last_name\": \"\",\n \"supports_inline_queries\": false,\n \"username\": \"\"\n }\n }\n ],\n \"explanation_parse_mode\": \"\",\n \"is_anonymous\": false,\n \"is_closed\": false,\n \"open_period\": 0,\n \"options\": [],\n \"question\": \"\",\n \"reply_markup\": \"\",\n \"reply_to_message_id\": 0,\n \"type\": \"\"\n}");
Request request = new Request.Builder()
.url("{{baseUrl}}/sendPoll")
.post(body)
.addHeader("content-type", "application/json")
.build();
Response response = client.newCall(request).execute();
HttpResponse response = Unirest.post("{{baseUrl}}/sendPoll")
.header("content-type", "application/json")
.body("{\n \"allow_sending_without_reply\": false,\n \"allows_multiple_answers\": false,\n \"chat_id\": \"\",\n \"close_date\": 0,\n \"correct_option_id\": 0,\n \"disable_notification\": false,\n \"explanation\": \"\",\n \"explanation_entities\": [\n {\n \"language\": \"\",\n \"length\": 0,\n \"offset\": 0,\n \"type\": \"\",\n \"url\": \"\",\n \"user\": {\n \"can_join_groups\": false,\n \"can_read_all_group_messages\": false,\n \"first_name\": \"\",\n \"id\": 0,\n \"is_bot\": false,\n \"language_code\": \"\",\n \"last_name\": \"\",\n \"supports_inline_queries\": false,\n \"username\": \"\"\n }\n }\n ],\n \"explanation_parse_mode\": \"\",\n \"is_anonymous\": false,\n \"is_closed\": false,\n \"open_period\": 0,\n \"options\": [],\n \"question\": \"\",\n \"reply_markup\": \"\",\n \"reply_to_message_id\": 0,\n \"type\": \"\"\n}")
.asString();
const data = JSON.stringify({
allow_sending_without_reply: false,
allows_multiple_answers: false,
chat_id: '',
close_date: 0,
correct_option_id: 0,
disable_notification: false,
explanation: '',
explanation_entities: [
{
language: '',
length: 0,
offset: 0,
type: '',
url: '',
user: {
can_join_groups: false,
can_read_all_group_messages: false,
first_name: '',
id: 0,
is_bot: false,
language_code: '',
last_name: '',
supports_inline_queries: false,
username: ''
}
}
],
explanation_parse_mode: '',
is_anonymous: false,
is_closed: false,
open_period: 0,
options: [],
question: '',
reply_markup: '',
reply_to_message_id: 0,
type: ''
});
const xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener('readystatechange', function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open('POST', '{{baseUrl}}/sendPoll');
xhr.setRequestHeader('content-type', 'application/json');
xhr.send(data);
import axios from 'axios';
const options = {
method: 'POST',
url: '{{baseUrl}}/sendPoll',
headers: {'content-type': 'application/json'},
data: {
allow_sending_without_reply: false,
allows_multiple_answers: false,
chat_id: '',
close_date: 0,
correct_option_id: 0,
disable_notification: false,
explanation: '',
explanation_entities: [
{
language: '',
length: 0,
offset: 0,
type: '',
url: '',
user: {
can_join_groups: false,
can_read_all_group_messages: false,
first_name: '',
id: 0,
is_bot: false,
language_code: '',
last_name: '',
supports_inline_queries: false,
username: ''
}
}
],
explanation_parse_mode: '',
is_anonymous: false,
is_closed: false,
open_period: 0,
options: [],
question: '',
reply_markup: '',
reply_to_message_id: 0,
type: ''
}
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const url = '{{baseUrl}}/sendPoll';
const options = {
method: 'POST',
headers: {'content-type': 'application/json'},
body: '{"allow_sending_without_reply":false,"allows_multiple_answers":false,"chat_id":"","close_date":0,"correct_option_id":0,"disable_notification":false,"explanation":"","explanation_entities":[{"language":"","length":0,"offset":0,"type":"","url":"","user":{"can_join_groups":false,"can_read_all_group_messages":false,"first_name":"","id":0,"is_bot":false,"language_code":"","last_name":"","supports_inline_queries":false,"username":""}}],"explanation_parse_mode":"","is_anonymous":false,"is_closed":false,"open_period":0,"options":[],"question":"","reply_markup":"","reply_to_message_id":0,"type":""}'
};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
const settings = {
async: true,
crossDomain: true,
url: '{{baseUrl}}/sendPoll',
method: 'POST',
headers: {
'content-type': 'application/json'
},
processData: false,
data: '{\n "allow_sending_without_reply": false,\n "allows_multiple_answers": false,\n "chat_id": "",\n "close_date": 0,\n "correct_option_id": 0,\n "disable_notification": false,\n "explanation": "",\n "explanation_entities": [\n {\n "language": "",\n "length": 0,\n "offset": 0,\n "type": "",\n "url": "",\n "user": {\n "can_join_groups": false,\n "can_read_all_group_messages": false,\n "first_name": "",\n "id": 0,\n "is_bot": false,\n "language_code": "",\n "last_name": "",\n "supports_inline_queries": false,\n "username": ""\n }\n }\n ],\n "explanation_parse_mode": "",\n "is_anonymous": false,\n "is_closed": false,\n "open_period": 0,\n "options": [],\n "question": "",\n "reply_markup": "",\n "reply_to_message_id": 0,\n "type": ""\n}'
};
$.ajax(settings).done(function (response) {
console.log(response);
});
val client = OkHttpClient()
val mediaType = MediaType.parse("application/json")
val body = RequestBody.create(mediaType, "{\n \"allow_sending_without_reply\": false,\n \"allows_multiple_answers\": false,\n \"chat_id\": \"\",\n \"close_date\": 0,\n \"correct_option_id\": 0,\n \"disable_notification\": false,\n \"explanation\": \"\",\n \"explanation_entities\": [\n {\n \"language\": \"\",\n \"length\": 0,\n \"offset\": 0,\n \"type\": \"\",\n \"url\": \"\",\n \"user\": {\n \"can_join_groups\": false,\n \"can_read_all_group_messages\": false,\n \"first_name\": \"\",\n \"id\": 0,\n \"is_bot\": false,\n \"language_code\": \"\",\n \"last_name\": \"\",\n \"supports_inline_queries\": false,\n \"username\": \"\"\n }\n }\n ],\n \"explanation_parse_mode\": \"\",\n \"is_anonymous\": false,\n \"is_closed\": false,\n \"open_period\": 0,\n \"options\": [],\n \"question\": \"\",\n \"reply_markup\": \"\",\n \"reply_to_message_id\": 0,\n \"type\": \"\"\n}")
val request = Request.Builder()
.url("{{baseUrl}}/sendPoll")
.post(body)
.addHeader("content-type", "application/json")
.build()
val response = client.newCall(request).execute()
const http = require('https');
const options = {
method: 'POST',
hostname: 'example.com',
port: null,
path: '/baseUrl/sendPoll',
headers: {
'content-type': 'application/json'
}
};
const req = http.request(options, function (res) {
const chunks = [];
res.on('data', function (chunk) {
chunks.push(chunk);
});
res.on('end', function () {
const body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.write(JSON.stringify({
allow_sending_without_reply: false,
allows_multiple_answers: false,
chat_id: '',
close_date: 0,
correct_option_id: 0,
disable_notification: false,
explanation: '',
explanation_entities: [
{
language: '',
length: 0,
offset: 0,
type: '',
url: '',
user: {
can_join_groups: false,
can_read_all_group_messages: false,
first_name: '',
id: 0,
is_bot: false,
language_code: '',
last_name: '',
supports_inline_queries: false,
username: ''
}
}
],
explanation_parse_mode: '',
is_anonymous: false,
is_closed: false,
open_period: 0,
options: [],
question: '',
reply_markup: '',
reply_to_message_id: 0,
type: ''
}));
req.end();
const request = require('request');
const options = {
method: 'POST',
url: '{{baseUrl}}/sendPoll',
headers: {'content-type': 'application/json'},
body: {
allow_sending_without_reply: false,
allows_multiple_answers: false,
chat_id: '',
close_date: 0,
correct_option_id: 0,
disable_notification: false,
explanation: '',
explanation_entities: [
{
language: '',
length: 0,
offset: 0,
type: '',
url: '',
user: {
can_join_groups: false,
can_read_all_group_messages: false,
first_name: '',
id: 0,
is_bot: false,
language_code: '',
last_name: '',
supports_inline_queries: false,
username: ''
}
}
],
explanation_parse_mode: '',
is_anonymous: false,
is_closed: false,
open_period: 0,
options: [],
question: '',
reply_markup: '',
reply_to_message_id: 0,
type: ''
},
json: true
};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
const unirest = require('unirest');
const req = unirest('POST', '{{baseUrl}}/sendPoll');
req.headers({
'content-type': 'application/json'
});
req.type('json');
req.send({
allow_sending_without_reply: false,
allows_multiple_answers: false,
chat_id: '',
close_date: 0,
correct_option_id: 0,
disable_notification: false,
explanation: '',
explanation_entities: [
{
language: '',
length: 0,
offset: 0,
type: '',
url: '',
user: {
can_join_groups: false,
can_read_all_group_messages: false,
first_name: '',
id: 0,
is_bot: false,
language_code: '',
last_name: '',
supports_inline_queries: false,
username: ''
}
}
],
explanation_parse_mode: '',
is_anonymous: false,
is_closed: false,
open_period: 0,
options: [],
question: '',
reply_markup: '',
reply_to_message_id: 0,
type: ''
});
req.end(function (res) {
if (res.error) throw new Error(res.error);
console.log(res.body);
});
const axios = require('axios').default;
const options = {
method: 'POST',
url: '{{baseUrl}}/sendPoll',
headers: {'content-type': 'application/json'},
data: {
allow_sending_without_reply: false,
allows_multiple_answers: false,
chat_id: '',
close_date: 0,
correct_option_id: 0,
disable_notification: false,
explanation: '',
explanation_entities: [
{
language: '',
length: 0,
offset: 0,
type: '',
url: '',
user: {
can_join_groups: false,
can_read_all_group_messages: false,
first_name: '',
id: 0,
is_bot: false,
language_code: '',
last_name: '',
supports_inline_queries: false,
username: ''
}
}
],
explanation_parse_mode: '',
is_anonymous: false,
is_closed: false,
open_period: 0,
options: [],
question: '',
reply_markup: '',
reply_to_message_id: 0,
type: ''
}
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const fetch = require('node-fetch');
const url = '{{baseUrl}}/sendPoll';
const options = {
method: 'POST',
headers: {'content-type': 'application/json'},
body: '{"allow_sending_without_reply":false,"allows_multiple_answers":false,"chat_id":"","close_date":0,"correct_option_id":0,"disable_notification":false,"explanation":"","explanation_entities":[{"language":"","length":0,"offset":0,"type":"","url":"","user":{"can_join_groups":false,"can_read_all_group_messages":false,"first_name":"","id":0,"is_bot":false,"language_code":"","last_name":"","supports_inline_queries":false,"username":""}}],"explanation_parse_mode":"","is_anonymous":false,"is_closed":false,"open_period":0,"options":[],"question":"","reply_markup":"","reply_to_message_id":0,"type":""}'
};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
#import
NSDictionary *headers = @{ @"content-type": @"application/json" };
NSDictionary *parameters = @{ @"allow_sending_without_reply": @NO,
@"allows_multiple_answers": @NO,
@"chat_id": @"",
@"close_date": @0,
@"correct_option_id": @0,
@"disable_notification": @NO,
@"explanation": @"",
@"explanation_entities": @[ @{ @"language": @"", @"length": @0, @"offset": @0, @"type": @"", @"url": @"", @"user": @{ @"can_join_groups": @NO, @"can_read_all_group_messages": @NO, @"first_name": @"", @"id": @0, @"is_bot": @NO, @"language_code": @"", @"last_name": @"", @"supports_inline_queries": @NO, @"username": @"" } } ],
@"explanation_parse_mode": @"",
@"is_anonymous": @NO,
@"is_closed": @NO,
@"open_period": @0,
@"options": @[ ],
@"question": @"",
@"reply_markup": @"",
@"reply_to_message_id": @0,
@"type": @"" };
NSData *postData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"{{baseUrl}}/sendPoll"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
[request setHTTPMethod:@"POST"];
[request setAllHTTPHeaderFields:headers];
[request setHTTPBody:postData];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSLog(@"%@", httpResponse);
}
}];
[dataTask resume];
open Cohttp_lwt_unix
open Cohttp
open Lwt
let uri = Uri.of_string "{{baseUrl}}/sendPoll" in
let headers = Header.add (Header.init ()) "content-type" "application/json" in
let body = Cohttp_lwt_body.of_string "{\n \"allow_sending_without_reply\": false,\n \"allows_multiple_answers\": false,\n \"chat_id\": \"\",\n \"close_date\": 0,\n \"correct_option_id\": 0,\n \"disable_notification\": false,\n \"explanation\": \"\",\n \"explanation_entities\": [\n {\n \"language\": \"\",\n \"length\": 0,\n \"offset\": 0,\n \"type\": \"\",\n \"url\": \"\",\n \"user\": {\n \"can_join_groups\": false,\n \"can_read_all_group_messages\": false,\n \"first_name\": \"\",\n \"id\": 0,\n \"is_bot\": false,\n \"language_code\": \"\",\n \"last_name\": \"\",\n \"supports_inline_queries\": false,\n \"username\": \"\"\n }\n }\n ],\n \"explanation_parse_mode\": \"\",\n \"is_anonymous\": false,\n \"is_closed\": false,\n \"open_period\": 0,\n \"options\": [],\n \"question\": \"\",\n \"reply_markup\": \"\",\n \"reply_to_message_id\": 0,\n \"type\": \"\"\n}" in
Client.call ~headers ~body `POST uri
>>= fun (res, body_stream) ->
(* Do stuff with the result *)
"{{baseUrl}}/sendPoll",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'allow_sending_without_reply' => null,
'allows_multiple_answers' => null,
'chat_id' => '',
'close_date' => 0,
'correct_option_id' => 0,
'disable_notification' => null,
'explanation' => '',
'explanation_entities' => [
[
'language' => '',
'length' => 0,
'offset' => 0,
'type' => '',
'url' => '',
'user' => [
'can_join_groups' => null,
'can_read_all_group_messages' => null,
'first_name' => '',
'id' => 0,
'is_bot' => null,
'language_code' => '',
'last_name' => '',
'supports_inline_queries' => null,
'username' => ''
]
]
],
'explanation_parse_mode' => '',
'is_anonymous' => null,
'is_closed' => null,
'open_period' => 0,
'options' => [
],
'question' => '',
'reply_markup' => '',
'reply_to_message_id' => 0,
'type' => ''
]),
CURLOPT_HTTPHEADER => [
"content-type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
request('POST', '{{baseUrl}}/sendPoll', [
'body' => '{
"allow_sending_without_reply": false,
"allows_multiple_answers": false,
"chat_id": "",
"close_date": 0,
"correct_option_id": 0,
"disable_notification": false,
"explanation": "",
"explanation_entities": [
{
"language": "",
"length": 0,
"offset": 0,
"type": "",
"url": "",
"user": {
"can_join_groups": false,
"can_read_all_group_messages": false,
"first_name": "",
"id": 0,
"is_bot": false,
"language_code": "",
"last_name": "",
"supports_inline_queries": false,
"username": ""
}
}
],
"explanation_parse_mode": "",
"is_anonymous": false,
"is_closed": false,
"open_period": 0,
"options": [],
"question": "",
"reply_markup": "",
"reply_to_message_id": 0,
"type": ""
}',
'headers' => [
'content-type' => 'application/json',
],
]);
echo $response->getBody();
setUrl('{{baseUrl}}/sendPoll');
$request->setMethod(HTTP_METH_POST);
$request->setHeaders([
'content-type' => 'application/json'
]);
$request->setContentType('application/json');
$request->setBody(json_encode([
'allow_sending_without_reply' => null,
'allows_multiple_answers' => null,
'chat_id' => '',
'close_date' => 0,
'correct_option_id' => 0,
'disable_notification' => null,
'explanation' => '',
'explanation_entities' => [
[
'language' => '',
'length' => 0,
'offset' => 0,
'type' => '',
'url' => '',
'user' => [
'can_join_groups' => null,
'can_read_all_group_messages' => null,
'first_name' => '',
'id' => 0,
'is_bot' => null,
'language_code' => '',
'last_name' => '',
'supports_inline_queries' => null,
'username' => ''
]
]
],
'explanation_parse_mode' => '',
'is_anonymous' => null,
'is_closed' => null,
'open_period' => 0,
'options' => [
],
'question' => '',
'reply_markup' => '',
'reply_to_message_id' => 0,
'type' => ''
]));
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
append(json_encode([
'allow_sending_without_reply' => null,
'allows_multiple_answers' => null,
'chat_id' => '',
'close_date' => 0,
'correct_option_id' => 0,
'disable_notification' => null,
'explanation' => '',
'explanation_entities' => [
[
'language' => '',
'length' => 0,
'offset' => 0,
'type' => '',
'url' => '',
'user' => [
'can_join_groups' => null,
'can_read_all_group_messages' => null,
'first_name' => '',
'id' => 0,
'is_bot' => null,
'language_code' => '',
'last_name' => '',
'supports_inline_queries' => null,
'username' => ''
]
]
],
'explanation_parse_mode' => '',
'is_anonymous' => null,
'is_closed' => null,
'open_period' => 0,
'options' => [
],
'question' => '',
'reply_markup' => '',
'reply_to_message_id' => 0,
'type' => ''
]));
$request->setRequestUrl('{{baseUrl}}/sendPoll');
$request->setRequestMethod('POST');
$request->setBody($body);
$request->setHeaders([
'content-type' => 'application/json'
]);
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
$headers=@{}
$headers.Add("content-type", "application/json")
$response = Invoke-WebRequest -Uri '{{baseUrl}}/sendPoll' -Method POST -Headers $headers -ContentType 'application/json' -Body '{
"allow_sending_without_reply": false,
"allows_multiple_answers": false,
"chat_id": "",
"close_date": 0,
"correct_option_id": 0,
"disable_notification": false,
"explanation": "",
"explanation_entities": [
{
"language": "",
"length": 0,
"offset": 0,
"type": "",
"url": "",
"user": {
"can_join_groups": false,
"can_read_all_group_messages": false,
"first_name": "",
"id": 0,
"is_bot": false,
"language_code": "",
"last_name": "",
"supports_inline_queries": false,
"username": ""
}
}
],
"explanation_parse_mode": "",
"is_anonymous": false,
"is_closed": false,
"open_period": 0,
"options": [],
"question": "",
"reply_markup": "",
"reply_to_message_id": 0,
"type": ""
}'
$headers=@{}
$headers.Add("content-type", "application/json")
$response = Invoke-RestMethod -Uri '{{baseUrl}}/sendPoll' -Method POST -Headers $headers -ContentType 'application/json' -Body '{
"allow_sending_without_reply": false,
"allows_multiple_answers": false,
"chat_id": "",
"close_date": 0,
"correct_option_id": 0,
"disable_notification": false,
"explanation": "",
"explanation_entities": [
{
"language": "",
"length": 0,
"offset": 0,
"type": "",
"url": "",
"user": {
"can_join_groups": false,
"can_read_all_group_messages": false,
"first_name": "",
"id": 0,
"is_bot": false,
"language_code": "",
"last_name": "",
"supports_inline_queries": false,
"username": ""
}
}
],
"explanation_parse_mode": "",
"is_anonymous": false,
"is_closed": false,
"open_period": 0,
"options": [],
"question": "",
"reply_markup": "",
"reply_to_message_id": 0,
"type": ""
}'
import http.client
conn = http.client.HTTPSConnection("example.com")
payload = "{\n \"allow_sending_without_reply\": false,\n \"allows_multiple_answers\": false,\n \"chat_id\": \"\",\n \"close_date\": 0,\n \"correct_option_id\": 0,\n \"disable_notification\": false,\n \"explanation\": \"\",\n \"explanation_entities\": [\n {\n \"language\": \"\",\n \"length\": 0,\n \"offset\": 0,\n \"type\": \"\",\n \"url\": \"\",\n \"user\": {\n \"can_join_groups\": false,\n \"can_read_all_group_messages\": false,\n \"first_name\": \"\",\n \"id\": 0,\n \"is_bot\": false,\n \"language_code\": \"\",\n \"last_name\": \"\",\n \"supports_inline_queries\": false,\n \"username\": \"\"\n }\n }\n ],\n \"explanation_parse_mode\": \"\",\n \"is_anonymous\": false,\n \"is_closed\": false,\n \"open_period\": 0,\n \"options\": [],\n \"question\": \"\",\n \"reply_markup\": \"\",\n \"reply_to_message_id\": 0,\n \"type\": \"\"\n}"
headers = { 'content-type': "application/json" }
conn.request("POST", "/baseUrl/sendPoll", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
import requests
url = "{{baseUrl}}/sendPoll"
payload = {
"allow_sending_without_reply": False,
"allows_multiple_answers": False,
"chat_id": "",
"close_date": 0,
"correct_option_id": 0,
"disable_notification": False,
"explanation": "",
"explanation_entities": [
{
"language": "",
"length": 0,
"offset": 0,
"type": "",
"url": "",
"user": {
"can_join_groups": False,
"can_read_all_group_messages": False,
"first_name": "",
"id": 0,
"is_bot": False,
"language_code": "",
"last_name": "",
"supports_inline_queries": False,
"username": ""
}
}
],
"explanation_parse_mode": "",
"is_anonymous": False,
"is_closed": False,
"open_period": 0,
"options": [],
"question": "",
"reply_markup": "",
"reply_to_message_id": 0,
"type": ""
}
headers = {"content-type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
library(httr)
url <- "{{baseUrl}}/sendPoll"
payload <- "{\n \"allow_sending_without_reply\": false,\n \"allows_multiple_answers\": false,\n \"chat_id\": \"\",\n \"close_date\": 0,\n \"correct_option_id\": 0,\n \"disable_notification\": false,\n \"explanation\": \"\",\n \"explanation_entities\": [\n {\n \"language\": \"\",\n \"length\": 0,\n \"offset\": 0,\n \"type\": \"\",\n \"url\": \"\",\n \"user\": {\n \"can_join_groups\": false,\n \"can_read_all_group_messages\": false,\n \"first_name\": \"\",\n \"id\": 0,\n \"is_bot\": false,\n \"language_code\": \"\",\n \"last_name\": \"\",\n \"supports_inline_queries\": false,\n \"username\": \"\"\n }\n }\n ],\n \"explanation_parse_mode\": \"\",\n \"is_anonymous\": false,\n \"is_closed\": false,\n \"open_period\": 0,\n \"options\": [],\n \"question\": \"\",\n \"reply_markup\": \"\",\n \"reply_to_message_id\": 0,\n \"type\": \"\"\n}"
encode <- "json"
response <- VERB("POST", url, body = payload, content_type("application/json"), encode = encode)
content(response, "text")
require 'uri'
require 'net/http'
url = URI("{{baseUrl}}/sendPoll")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["content-type"] = 'application/json'
request.body = "{\n \"allow_sending_without_reply\": false,\n \"allows_multiple_answers\": false,\n \"chat_id\": \"\",\n \"close_date\": 0,\n \"correct_option_id\": 0,\n \"disable_notification\": false,\n \"explanation\": \"\",\n \"explanation_entities\": [\n {\n \"language\": \"\",\n \"length\": 0,\n \"offset\": 0,\n \"type\": \"\",\n \"url\": \"\",\n \"user\": {\n \"can_join_groups\": false,\n \"can_read_all_group_messages\": false,\n \"first_name\": \"\",\n \"id\": 0,\n \"is_bot\": false,\n \"language_code\": \"\",\n \"last_name\": \"\",\n \"supports_inline_queries\": false,\n \"username\": \"\"\n }\n }\n ],\n \"explanation_parse_mode\": \"\",\n \"is_anonymous\": false,\n \"is_closed\": false,\n \"open_period\": 0,\n \"options\": [],\n \"question\": \"\",\n \"reply_markup\": \"\",\n \"reply_to_message_id\": 0,\n \"type\": \"\"\n}"
response = http.request(request)
puts response.read_body
require 'faraday'
conn = Faraday.new(
url: 'https://example.com',
headers: {'Content-Type' => 'application/json'}
)
response = conn.post('/baseUrl/sendPoll') do |req|
req.body = "{\n \"allow_sending_without_reply\": false,\n \"allows_multiple_answers\": false,\n \"chat_id\": \"\",\n \"close_date\": 0,\n \"correct_option_id\": 0,\n \"disable_notification\": false,\n \"explanation\": \"\",\n \"explanation_entities\": [\n {\n \"language\": \"\",\n \"length\": 0,\n \"offset\": 0,\n \"type\": \"\",\n \"url\": \"\",\n \"user\": {\n \"can_join_groups\": false,\n \"can_read_all_group_messages\": false,\n \"first_name\": \"\",\n \"id\": 0,\n \"is_bot\": false,\n \"language_code\": \"\",\n \"last_name\": \"\",\n \"supports_inline_queries\": false,\n \"username\": \"\"\n }\n }\n ],\n \"explanation_parse_mode\": \"\",\n \"is_anonymous\": false,\n \"is_closed\": false,\n \"open_period\": 0,\n \"options\": [],\n \"question\": \"\",\n \"reply_markup\": \"\",\n \"reply_to_message_id\": 0,\n \"type\": \"\"\n}"
end
puts response.status
puts response.body
use serde_json::json;
use reqwest;
#[tokio::main]
pub async fn main() {
let url = "{{baseUrl}}/sendPoll";
let payload = json!({
"allow_sending_without_reply": false,
"allows_multiple_answers": false,
"chat_id": "",
"close_date": 0,
"correct_option_id": 0,
"disable_notification": false,
"explanation": "",
"explanation_entities": (
json!({
"language": "",
"length": 0,
"offset": 0,
"type": "",
"url": "",
"user": json!({
"can_join_groups": false,
"can_read_all_group_messages": false,
"first_name": "",
"id": 0,
"is_bot": false,
"language_code": "",
"last_name": "",
"supports_inline_queries": false,
"username": ""
})
})
),
"explanation_parse_mode": "",
"is_anonymous": false,
"is_closed": false,
"open_period": 0,
"options": (),
"question": "",
"reply_markup": "",
"reply_to_message_id": 0,
"type": ""
});
let mut headers = reqwest::header::HeaderMap::new();
headers.insert("content-type", "application/json".parse().unwrap());
let client = reqwest::Client::new();
let response = client.post(url)
.headers(headers)
.json(&payload)
.send()
.await;
let results = response.unwrap()
.json::()
.await
.unwrap();
dbg!(results);
}
curl --request POST \
--url {{baseUrl}}/sendPoll \
--header 'content-type: application/json' \
--data '{
"allow_sending_without_reply": false,
"allows_multiple_answers": false,
"chat_id": "",
"close_date": 0,
"correct_option_id": 0,
"disable_notification": false,
"explanation": "",
"explanation_entities": [
{
"language": "",
"length": 0,
"offset": 0,
"type": "",
"url": "",
"user": {
"can_join_groups": false,
"can_read_all_group_messages": false,
"first_name": "",
"id": 0,
"is_bot": false,
"language_code": "",
"last_name": "",
"supports_inline_queries": false,
"username": ""
}
}
],
"explanation_parse_mode": "",
"is_anonymous": false,
"is_closed": false,
"open_period": 0,
"options": [],
"question": "",
"reply_markup": "",
"reply_to_message_id": 0,
"type": ""
}'
echo '{
"allow_sending_without_reply": false,
"allows_multiple_answers": false,
"chat_id": "",
"close_date": 0,
"correct_option_id": 0,
"disable_notification": false,
"explanation": "",
"explanation_entities": [
{
"language": "",
"length": 0,
"offset": 0,
"type": "",
"url": "",
"user": {
"can_join_groups": false,
"can_read_all_group_messages": false,
"first_name": "",
"id": 0,
"is_bot": false,
"language_code": "",
"last_name": "",
"supports_inline_queries": false,
"username": ""
}
}
],
"explanation_parse_mode": "",
"is_anonymous": false,
"is_closed": false,
"open_period": 0,
"options": [],
"question": "",
"reply_markup": "",
"reply_to_message_id": 0,
"type": ""
}' | \
http POST {{baseUrl}}/sendPoll \
content-type:application/json
wget --quiet \
--method POST \
--header 'content-type: application/json' \
--body-data '{\n "allow_sending_without_reply": false,\n "allows_multiple_answers": false,\n "chat_id": "",\n "close_date": 0,\n "correct_option_id": 0,\n "disable_notification": false,\n "explanation": "",\n "explanation_entities": [\n {\n "language": "",\n "length": 0,\n "offset": 0,\n "type": "",\n "url": "",\n "user": {\n "can_join_groups": false,\n "can_read_all_group_messages": false,\n "first_name": "",\n "id": 0,\n "is_bot": false,\n "language_code": "",\n "last_name": "",\n "supports_inline_queries": false,\n "username": ""\n }\n }\n ],\n "explanation_parse_mode": "",\n "is_anonymous": false,\n "is_closed": false,\n "open_period": 0,\n "options": [],\n "question": "",\n "reply_markup": "",\n "reply_to_message_id": 0,\n "type": ""\n}' \
--output-document \
- {{baseUrl}}/sendPoll
import Foundation
let headers = ["content-type": "application/json"]
let parameters = [
"allow_sending_without_reply": false,
"allows_multiple_answers": false,
"chat_id": "",
"close_date": 0,
"correct_option_id": 0,
"disable_notification": false,
"explanation": "",
"explanation_entities": [
[
"language": "",
"length": 0,
"offset": 0,
"type": "",
"url": "",
"user": [
"can_join_groups": false,
"can_read_all_group_messages": false,
"first_name": "",
"id": 0,
"is_bot": false,
"language_code": "",
"last_name": "",
"supports_inline_queries": false,
"username": ""
]
]
],
"explanation_parse_mode": "",
"is_anonymous": false,
"is_closed": false,
"open_period": 0,
"options": [],
"question": "",
"reply_markup": "",
"reply_to_message_id": 0,
"type": ""
] as [String : Any]
let postData = JSONSerialization.data(withJSONObject: parameters, options: [])
let request = NSMutableURLRequest(url: NSURL(string: "{{baseUrl}}/sendPoll")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error as Any)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
POST
Use this method to send an animated emoji that will display a random value. On success, the sent [Message](https---core.telegram.org-bots-api-#message) is returned.
{{baseUrl}}/sendDice
BODY json
{
"allow_sending_without_reply": false,
"chat_id": "",
"disable_notification": false,
"emoji": "",
"reply_markup": "",
"reply_to_message_id": 0
}
Examples
REQUEST
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(hnd, CURLOPT_URL, "{{baseUrl}}/sendDice");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "content-type: application/json");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "{\n \"allow_sending_without_reply\": false,\n \"chat_id\": \"\",\n \"disable_notification\": false,\n \"emoji\": \"\",\n \"reply_markup\": \"\",\n \"reply_to_message_id\": 0\n}");
CURLcode ret = curl_easy_perform(hnd);
(require '[clj-http.client :as client])
(client/post "{{baseUrl}}/sendDice" {:content-type :json
:form-params {:allow_sending_without_reply false
:chat_id ""
:disable_notification false
:emoji ""
:reply_markup ""
:reply_to_message_id 0}})
require "http/client"
url = "{{baseUrl}}/sendDice"
headers = HTTP::Headers{
"content-type" => "application/json"
}
reqBody = "{\n \"allow_sending_without_reply\": false,\n \"chat_id\": \"\",\n \"disable_notification\": false,\n \"emoji\": \"\",\n \"reply_markup\": \"\",\n \"reply_to_message_id\": 0\n}"
response = HTTP::Client.post url, headers: headers, body: reqBody
puts response.body
using System.Net.Http.Headers;
var client = new HttpClient();
var request = new HttpRequestMessage
{
Method = HttpMethod.Post,
RequestUri = new Uri("{{baseUrl}}/sendDice"),
Content = new StringContent("{\n \"allow_sending_without_reply\": false,\n \"chat_id\": \"\",\n \"disable_notification\": false,\n \"emoji\": \"\",\n \"reply_markup\": \"\",\n \"reply_to_message_id\": 0\n}")
{
Headers =
{
ContentType = new MediaTypeHeaderValue("application/json")
}
}
};
using (var response = await client.SendAsync(request))
{
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
}
var client = new RestClient("{{baseUrl}}/sendDice");
var request = new RestRequest("", Method.Post);
request.AddHeader("content-type", "application/json");
request.AddParameter("application/json", "{\n \"allow_sending_without_reply\": false,\n \"chat_id\": \"\",\n \"disable_notification\": false,\n \"emoji\": \"\",\n \"reply_markup\": \"\",\n \"reply_to_message_id\": 0\n}", ParameterType.RequestBody);
var response = client.Execute(request);
package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "{{baseUrl}}/sendDice"
payload := strings.NewReader("{\n \"allow_sending_without_reply\": false,\n \"chat_id\": \"\",\n \"disable_notification\": false,\n \"emoji\": \"\",\n \"reply_markup\": \"\",\n \"reply_to_message_id\": 0\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("content-type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
POST /baseUrl/sendDice HTTP/1.1
Content-Type: application/json
Host: example.com
Content-Length: 157
{
"allow_sending_without_reply": false,
"chat_id": "",
"disable_notification": false,
"emoji": "",
"reply_markup": "",
"reply_to_message_id": 0
}
AsyncHttpClient client = new DefaultAsyncHttpClient();
client.prepare("POST", "{{baseUrl}}/sendDice")
.setHeader("content-type", "application/json")
.setBody("{\n \"allow_sending_without_reply\": false,\n \"chat_id\": \"\",\n \"disable_notification\": false,\n \"emoji\": \"\",\n \"reply_markup\": \"\",\n \"reply_to_message_id\": 0\n}")
.execute()
.toCompletableFuture()
.thenAccept(System.out::println)
.join();
client.close();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("{{baseUrl}}/sendDice"))
.header("content-type", "application/json")
.method("POST", HttpRequest.BodyPublishers.ofString("{\n \"allow_sending_without_reply\": false,\n \"chat_id\": \"\",\n \"disable_notification\": false,\n \"emoji\": \"\",\n \"reply_markup\": \"\",\n \"reply_to_message_id\": 0\n}"))
.build();
HttpResponse response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n \"allow_sending_without_reply\": false,\n \"chat_id\": \"\",\n \"disable_notification\": false,\n \"emoji\": \"\",\n \"reply_markup\": \"\",\n \"reply_to_message_id\": 0\n}");
Request request = new Request.Builder()
.url("{{baseUrl}}/sendDice")
.post(body)
.addHeader("content-type", "application/json")
.build();
Response response = client.newCall(request).execute();
HttpResponse response = Unirest.post("{{baseUrl}}/sendDice")
.header("content-type", "application/json")
.body("{\n \"allow_sending_without_reply\": false,\n \"chat_id\": \"\",\n \"disable_notification\": false,\n \"emoji\": \"\",\n \"reply_markup\": \"\",\n \"reply_to_message_id\": 0\n}")
.asString();
const data = JSON.stringify({
allow_sending_without_reply: false,
chat_id: '',
disable_notification: false,
emoji: '',
reply_markup: '',
reply_to_message_id: 0
});
const xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener('readystatechange', function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open('POST', '{{baseUrl}}/sendDice');
xhr.setRequestHeader('content-type', 'application/json');
xhr.send(data);
import axios from 'axios';
const options = {
method: 'POST',
url: '{{baseUrl}}/sendDice',
headers: {'content-type': 'application/json'},
data: {
allow_sending_without_reply: false,
chat_id: '',
disable_notification: false,
emoji: '',
reply_markup: '',
reply_to_message_id: 0
}
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const url = '{{baseUrl}}/sendDice';
const options = {
method: 'POST',
headers: {'content-type': 'application/json'},
body: '{"allow_sending_without_reply":false,"chat_id":"","disable_notification":false,"emoji":"","reply_markup":"","reply_to_message_id":0}'
};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
const settings = {
async: true,
crossDomain: true,
url: '{{baseUrl}}/sendDice',
method: 'POST',
headers: {
'content-type': 'application/json'
},
processData: false,
data: '{\n "allow_sending_without_reply": false,\n "chat_id": "",\n "disable_notification": false,\n "emoji": "",\n "reply_markup": "",\n "reply_to_message_id": 0\n}'
};
$.ajax(settings).done(function (response) {
console.log(response);
});
val client = OkHttpClient()
val mediaType = MediaType.parse("application/json")
val body = RequestBody.create(mediaType, "{\n \"allow_sending_without_reply\": false,\n \"chat_id\": \"\",\n \"disable_notification\": false,\n \"emoji\": \"\",\n \"reply_markup\": \"\",\n \"reply_to_message_id\": 0\n}")
val request = Request.Builder()
.url("{{baseUrl}}/sendDice")
.post(body)
.addHeader("content-type", "application/json")
.build()
val response = client.newCall(request).execute()
const http = require('https');
const options = {
method: 'POST',
hostname: 'example.com',
port: null,
path: '/baseUrl/sendDice',
headers: {
'content-type': 'application/json'
}
};
const req = http.request(options, function (res) {
const chunks = [];
res.on('data', function (chunk) {
chunks.push(chunk);
});
res.on('end', function () {
const body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.write(JSON.stringify({
allow_sending_without_reply: false,
chat_id: '',
disable_notification: false,
emoji: '',
reply_markup: '',
reply_to_message_id: 0
}));
req.end();
const request = require('request');
const options = {
method: 'POST',
url: '{{baseUrl}}/sendDice',
headers: {'content-type': 'application/json'},
body: {
allow_sending_without_reply: false,
chat_id: '',
disable_notification: false,
emoji: '',
reply_markup: '',
reply_to_message_id: 0
},
json: true
};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
const unirest = require('unirest');
const req = unirest('POST', '{{baseUrl}}/sendDice');
req.headers({
'content-type': 'application/json'
});
req.type('json');
req.send({
allow_sending_without_reply: false,
chat_id: '',
disable_notification: false,
emoji: '',
reply_markup: '',
reply_to_message_id: 0
});
req.end(function (res) {
if (res.error) throw new Error(res.error);
console.log(res.body);
});
const axios = require('axios').default;
const options = {
method: 'POST',
url: '{{baseUrl}}/sendDice',
headers: {'content-type': 'application/json'},
data: {
allow_sending_without_reply: false,
chat_id: '',
disable_notification: false,
emoji: '',
reply_markup: '',
reply_to_message_id: 0
}
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const fetch = require('node-fetch');
const url = '{{baseUrl}}/sendDice';
const options = {
method: 'POST',
headers: {'content-type': 'application/json'},
body: '{"allow_sending_without_reply":false,"chat_id":"","disable_notification":false,"emoji":"","reply_markup":"","reply_to_message_id":0}'
};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
#import
NSDictionary *headers = @{ @"content-type": @"application/json" };
NSDictionary *parameters = @{ @"allow_sending_without_reply": @NO,
@"chat_id": @"",
@"disable_notification": @NO,
@"emoji": @"",
@"reply_markup": @"",
@"reply_to_message_id": @0 };
NSData *postData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"{{baseUrl}}/sendDice"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
[request setHTTPMethod:@"POST"];
[request setAllHTTPHeaderFields:headers];
[request setHTTPBody:postData];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSLog(@"%@", httpResponse);
}
}];
[dataTask resume];
open Cohttp_lwt_unix
open Cohttp
open Lwt
let uri = Uri.of_string "{{baseUrl}}/sendDice" in
let headers = Header.add (Header.init ()) "content-type" "application/json" in
let body = Cohttp_lwt_body.of_string "{\n \"allow_sending_without_reply\": false,\n \"chat_id\": \"\",\n \"disable_notification\": false,\n \"emoji\": \"\",\n \"reply_markup\": \"\",\n \"reply_to_message_id\": 0\n}" in
Client.call ~headers ~body `POST uri
>>= fun (res, body_stream) ->
(* Do stuff with the result *)
"{{baseUrl}}/sendDice",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'allow_sending_without_reply' => null,
'chat_id' => '',
'disable_notification' => null,
'emoji' => '',
'reply_markup' => '',
'reply_to_message_id' => 0
]),
CURLOPT_HTTPHEADER => [
"content-type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
request('POST', '{{baseUrl}}/sendDice', [
'body' => '{
"allow_sending_without_reply": false,
"chat_id": "",
"disable_notification": false,
"emoji": "",
"reply_markup": "",
"reply_to_message_id": 0
}',
'headers' => [
'content-type' => 'application/json',
],
]);
echo $response->getBody();
setUrl('{{baseUrl}}/sendDice');
$request->setMethod(HTTP_METH_POST);
$request->setHeaders([
'content-type' => 'application/json'
]);
$request->setContentType('application/json');
$request->setBody(json_encode([
'allow_sending_without_reply' => null,
'chat_id' => '',
'disable_notification' => null,
'emoji' => '',
'reply_markup' => '',
'reply_to_message_id' => 0
]));
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
append(json_encode([
'allow_sending_without_reply' => null,
'chat_id' => '',
'disable_notification' => null,
'emoji' => '',
'reply_markup' => '',
'reply_to_message_id' => 0
]));
$request->setRequestUrl('{{baseUrl}}/sendDice');
$request->setRequestMethod('POST');
$request->setBody($body);
$request->setHeaders([
'content-type' => 'application/json'
]);
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
$headers=@{}
$headers.Add("content-type", "application/json")
$response = Invoke-WebRequest -Uri '{{baseUrl}}/sendDice' -Method POST -Headers $headers -ContentType 'application/json' -Body '{
"allow_sending_without_reply": false,
"chat_id": "",
"disable_notification": false,
"emoji": "",
"reply_markup": "",
"reply_to_message_id": 0
}'
$headers=@{}
$headers.Add("content-type", "application/json")
$response = Invoke-RestMethod -Uri '{{baseUrl}}/sendDice' -Method POST -Headers $headers -ContentType 'application/json' -Body '{
"allow_sending_without_reply": false,
"chat_id": "",
"disable_notification": false,
"emoji": "",
"reply_markup": "",
"reply_to_message_id": 0
}'
import http.client
conn = http.client.HTTPSConnection("example.com")
payload = "{\n \"allow_sending_without_reply\": false,\n \"chat_id\": \"\",\n \"disable_notification\": false,\n \"emoji\": \"\",\n \"reply_markup\": \"\",\n \"reply_to_message_id\": 0\n}"
headers = { 'content-type': "application/json" }
conn.request("POST", "/baseUrl/sendDice", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
import requests
url = "{{baseUrl}}/sendDice"
payload = {
"allow_sending_without_reply": False,
"chat_id": "",
"disable_notification": False,
"emoji": "",
"reply_markup": "",
"reply_to_message_id": 0
}
headers = {"content-type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
library(httr)
url <- "{{baseUrl}}/sendDice"
payload <- "{\n \"allow_sending_without_reply\": false,\n \"chat_id\": \"\",\n \"disable_notification\": false,\n \"emoji\": \"\",\n \"reply_markup\": \"\",\n \"reply_to_message_id\": 0\n}"
encode <- "json"
response <- VERB("POST", url, body = payload, content_type("application/json"), encode = encode)
content(response, "text")
require 'uri'
require 'net/http'
url = URI("{{baseUrl}}/sendDice")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["content-type"] = 'application/json'
request.body = "{\n \"allow_sending_without_reply\": false,\n \"chat_id\": \"\",\n \"disable_notification\": false,\n \"emoji\": \"\",\n \"reply_markup\": \"\",\n \"reply_to_message_id\": 0\n}"
response = http.request(request)
puts response.read_body
require 'faraday'
conn = Faraday.new(
url: 'https://example.com',
headers: {'Content-Type' => 'application/json'}
)
response = conn.post('/baseUrl/sendDice') do |req|
req.body = "{\n \"allow_sending_without_reply\": false,\n \"chat_id\": \"\",\n \"disable_notification\": false,\n \"emoji\": \"\",\n \"reply_markup\": \"\",\n \"reply_to_message_id\": 0\n}"
end
puts response.status
puts response.body
use serde_json::json;
use reqwest;
#[tokio::main]
pub async fn main() {
let url = "{{baseUrl}}/sendDice";
let payload = json!({
"allow_sending_without_reply": false,
"chat_id": "",
"disable_notification": false,
"emoji": "",
"reply_markup": "",
"reply_to_message_id": 0
});
let mut headers = reqwest::header::HeaderMap::new();
headers.insert("content-type", "application/json".parse().unwrap());
let client = reqwest::Client::new();
let response = client.post(url)
.headers(headers)
.json(&payload)
.send()
.await;
let results = response.unwrap()
.json::()
.await
.unwrap();
dbg!(results);
}
curl --request POST \
--url {{baseUrl}}/sendDice \
--header 'content-type: application/json' \
--data '{
"allow_sending_without_reply": false,
"chat_id": "",
"disable_notification": false,
"emoji": "",
"reply_markup": "",
"reply_to_message_id": 0
}'
echo '{
"allow_sending_without_reply": false,
"chat_id": "",
"disable_notification": false,
"emoji": "",
"reply_markup": "",
"reply_to_message_id": 0
}' | \
http POST {{baseUrl}}/sendDice \
content-type:application/json
wget --quiet \
--method POST \
--header 'content-type: application/json' \
--body-data '{\n "allow_sending_without_reply": false,\n "chat_id": "",\n "disable_notification": false,\n "emoji": "",\n "reply_markup": "",\n "reply_to_message_id": 0\n}' \
--output-document \
- {{baseUrl}}/sendDice
import Foundation
let headers = ["content-type": "application/json"]
let parameters = [
"allow_sending_without_reply": false,
"chat_id": "",
"disable_notification": false,
"emoji": "",
"reply_markup": "",
"reply_to_message_id": 0
] as [String : Any]
let postData = JSONSerialization.data(withJSONObject: parameters, options: [])
let request = NSMutableURLRequest(url: NSURL(string: "{{baseUrl}}/sendDice")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error as Any)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
POST
Use this method to send answers to an inline query. On success, -True- is returned. No more than --50-- results per query are allowed.
{{baseUrl}}/answerInlineQuery
BODY json
{
"cache_time": 0,
"inline_query_id": "",
"is_personal": false,
"next_offset": "",
"results": [],
"switch_pm_parameter": "",
"switch_pm_text": ""
}
Examples
REQUEST
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(hnd, CURLOPT_URL, "{{baseUrl}}/answerInlineQuery");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "content-type: application/json");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "{\n \"cache_time\": 0,\n \"inline_query_id\": \"\",\n \"is_personal\": false,\n \"next_offset\": \"\",\n \"results\": [],\n \"switch_pm_parameter\": \"\",\n \"switch_pm_text\": \"\"\n}");
CURLcode ret = curl_easy_perform(hnd);
(require '[clj-http.client :as client])
(client/post "{{baseUrl}}/answerInlineQuery" {:content-type :json
:form-params {:cache_time 0
:inline_query_id ""
:is_personal false
:next_offset ""
:results []
:switch_pm_parameter ""
:switch_pm_text ""}})
require "http/client"
url = "{{baseUrl}}/answerInlineQuery"
headers = HTTP::Headers{
"content-type" => "application/json"
}
reqBody = "{\n \"cache_time\": 0,\n \"inline_query_id\": \"\",\n \"is_personal\": false,\n \"next_offset\": \"\",\n \"results\": [],\n \"switch_pm_parameter\": \"\",\n \"switch_pm_text\": \"\"\n}"
response = HTTP::Client.post url, headers: headers, body: reqBody
puts response.body
using System.Net.Http.Headers;
var client = new HttpClient();
var request = new HttpRequestMessage
{
Method = HttpMethod.Post,
RequestUri = new Uri("{{baseUrl}}/answerInlineQuery"),
Content = new StringContent("{\n \"cache_time\": 0,\n \"inline_query_id\": \"\",\n \"is_personal\": false,\n \"next_offset\": \"\",\n \"results\": [],\n \"switch_pm_parameter\": \"\",\n \"switch_pm_text\": \"\"\n}")
{
Headers =
{
ContentType = new MediaTypeHeaderValue("application/json")
}
}
};
using (var response = await client.SendAsync(request))
{
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
}
var client = new RestClient("{{baseUrl}}/answerInlineQuery");
var request = new RestRequest("", Method.Post);
request.AddHeader("content-type", "application/json");
request.AddParameter("application/json", "{\n \"cache_time\": 0,\n \"inline_query_id\": \"\",\n \"is_personal\": false,\n \"next_offset\": \"\",\n \"results\": [],\n \"switch_pm_parameter\": \"\",\n \"switch_pm_text\": \"\"\n}", ParameterType.RequestBody);
var response = client.Execute(request);
package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "{{baseUrl}}/answerInlineQuery"
payload := strings.NewReader("{\n \"cache_time\": 0,\n \"inline_query_id\": \"\",\n \"is_personal\": false,\n \"next_offset\": \"\",\n \"results\": [],\n \"switch_pm_parameter\": \"\",\n \"switch_pm_text\": \"\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("content-type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
POST /baseUrl/answerInlineQuery HTTP/1.1
Content-Type: application/json
Host: example.com
Content-Length: 161
{
"cache_time": 0,
"inline_query_id": "",
"is_personal": false,
"next_offset": "",
"results": [],
"switch_pm_parameter": "",
"switch_pm_text": ""
}
AsyncHttpClient client = new DefaultAsyncHttpClient();
client.prepare("POST", "{{baseUrl}}/answerInlineQuery")
.setHeader("content-type", "application/json")
.setBody("{\n \"cache_time\": 0,\n \"inline_query_id\": \"\",\n \"is_personal\": false,\n \"next_offset\": \"\",\n \"results\": [],\n \"switch_pm_parameter\": \"\",\n \"switch_pm_text\": \"\"\n}")
.execute()
.toCompletableFuture()
.thenAccept(System.out::println)
.join();
client.close();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("{{baseUrl}}/answerInlineQuery"))
.header("content-type", "application/json")
.method("POST", HttpRequest.BodyPublishers.ofString("{\n \"cache_time\": 0,\n \"inline_query_id\": \"\",\n \"is_personal\": false,\n \"next_offset\": \"\",\n \"results\": [],\n \"switch_pm_parameter\": \"\",\n \"switch_pm_text\": \"\"\n}"))
.build();
HttpResponse response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n \"cache_time\": 0,\n \"inline_query_id\": \"\",\n \"is_personal\": false,\n \"next_offset\": \"\",\n \"results\": [],\n \"switch_pm_parameter\": \"\",\n \"switch_pm_text\": \"\"\n}");
Request request = new Request.Builder()
.url("{{baseUrl}}/answerInlineQuery")
.post(body)
.addHeader("content-type", "application/json")
.build();
Response response = client.newCall(request).execute();
HttpResponse response = Unirest.post("{{baseUrl}}/answerInlineQuery")
.header("content-type", "application/json")
.body("{\n \"cache_time\": 0,\n \"inline_query_id\": \"\",\n \"is_personal\": false,\n \"next_offset\": \"\",\n \"results\": [],\n \"switch_pm_parameter\": \"\",\n \"switch_pm_text\": \"\"\n}")
.asString();
const data = JSON.stringify({
cache_time: 0,
inline_query_id: '',
is_personal: false,
next_offset: '',
results: [],
switch_pm_parameter: '',
switch_pm_text: ''
});
const xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener('readystatechange', function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open('POST', '{{baseUrl}}/answerInlineQuery');
xhr.setRequestHeader('content-type', 'application/json');
xhr.send(data);
import axios from 'axios';
const options = {
method: 'POST',
url: '{{baseUrl}}/answerInlineQuery',
headers: {'content-type': 'application/json'},
data: {
cache_time: 0,
inline_query_id: '',
is_personal: false,
next_offset: '',
results: [],
switch_pm_parameter: '',
switch_pm_text: ''
}
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const url = '{{baseUrl}}/answerInlineQuery';
const options = {
method: 'POST',
headers: {'content-type': 'application/json'},
body: '{"cache_time":0,"inline_query_id":"","is_personal":false,"next_offset":"","results":[],"switch_pm_parameter":"","switch_pm_text":""}'
};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
const settings = {
async: true,
crossDomain: true,
url: '{{baseUrl}}/answerInlineQuery',
method: 'POST',
headers: {
'content-type': 'application/json'
},
processData: false,
data: '{\n "cache_time": 0,\n "inline_query_id": "",\n "is_personal": false,\n "next_offset": "",\n "results": [],\n "switch_pm_parameter": "",\n "switch_pm_text": ""\n}'
};
$.ajax(settings).done(function (response) {
console.log(response);
});
val client = OkHttpClient()
val mediaType = MediaType.parse("application/json")
val body = RequestBody.create(mediaType, "{\n \"cache_time\": 0,\n \"inline_query_id\": \"\",\n \"is_personal\": false,\n \"next_offset\": \"\",\n \"results\": [],\n \"switch_pm_parameter\": \"\",\n \"switch_pm_text\": \"\"\n}")
val request = Request.Builder()
.url("{{baseUrl}}/answerInlineQuery")
.post(body)
.addHeader("content-type", "application/json")
.build()
val response = client.newCall(request).execute()
const http = require('https');
const options = {
method: 'POST',
hostname: 'example.com',
port: null,
path: '/baseUrl/answerInlineQuery',
headers: {
'content-type': 'application/json'
}
};
const req = http.request(options, function (res) {
const chunks = [];
res.on('data', function (chunk) {
chunks.push(chunk);
});
res.on('end', function () {
const body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.write(JSON.stringify({
cache_time: 0,
inline_query_id: '',
is_personal: false,
next_offset: '',
results: [],
switch_pm_parameter: '',
switch_pm_text: ''
}));
req.end();
const request = require('request');
const options = {
method: 'POST',
url: '{{baseUrl}}/answerInlineQuery',
headers: {'content-type': 'application/json'},
body: {
cache_time: 0,
inline_query_id: '',
is_personal: false,
next_offset: '',
results: [],
switch_pm_parameter: '',
switch_pm_text: ''
},
json: true
};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
const unirest = require('unirest');
const req = unirest('POST', '{{baseUrl}}/answerInlineQuery');
req.headers({
'content-type': 'application/json'
});
req.type('json');
req.send({
cache_time: 0,
inline_query_id: '',
is_personal: false,
next_offset: '',
results: [],
switch_pm_parameter: '',
switch_pm_text: ''
});
req.end(function (res) {
if (res.error) throw new Error(res.error);
console.log(res.body);
});
const axios = require('axios').default;
const options = {
method: 'POST',
url: '{{baseUrl}}/answerInlineQuery',
headers: {'content-type': 'application/json'},
data: {
cache_time: 0,
inline_query_id: '',
is_personal: false,
next_offset: '',
results: [],
switch_pm_parameter: '',
switch_pm_text: ''
}
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const fetch = require('node-fetch');
const url = '{{baseUrl}}/answerInlineQuery';
const options = {
method: 'POST',
headers: {'content-type': 'application/json'},
body: '{"cache_time":0,"inline_query_id":"","is_personal":false,"next_offset":"","results":[],"switch_pm_parameter":"","switch_pm_text":""}'
};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
#import
NSDictionary *headers = @{ @"content-type": @"application/json" };
NSDictionary *parameters = @{ @"cache_time": @0,
@"inline_query_id": @"",
@"is_personal": @NO,
@"next_offset": @"",
@"results": @[ ],
@"switch_pm_parameter": @"",
@"switch_pm_text": @"" };
NSData *postData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"{{baseUrl}}/answerInlineQuery"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
[request setHTTPMethod:@"POST"];
[request setAllHTTPHeaderFields:headers];
[request setHTTPBody:postData];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSLog(@"%@", httpResponse);
}
}];
[dataTask resume];
open Cohttp_lwt_unix
open Cohttp
open Lwt
let uri = Uri.of_string "{{baseUrl}}/answerInlineQuery" in
let headers = Header.add (Header.init ()) "content-type" "application/json" in
let body = Cohttp_lwt_body.of_string "{\n \"cache_time\": 0,\n \"inline_query_id\": \"\",\n \"is_personal\": false,\n \"next_offset\": \"\",\n \"results\": [],\n \"switch_pm_parameter\": \"\",\n \"switch_pm_text\": \"\"\n}" in
Client.call ~headers ~body `POST uri
>>= fun (res, body_stream) ->
(* Do stuff with the result *)
"{{baseUrl}}/answerInlineQuery",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'cache_time' => 0,
'inline_query_id' => '',
'is_personal' => null,
'next_offset' => '',
'results' => [
],
'switch_pm_parameter' => '',
'switch_pm_text' => ''
]),
CURLOPT_HTTPHEADER => [
"content-type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
request('POST', '{{baseUrl}}/answerInlineQuery', [
'body' => '{
"cache_time": 0,
"inline_query_id": "",
"is_personal": false,
"next_offset": "",
"results": [],
"switch_pm_parameter": "",
"switch_pm_text": ""
}',
'headers' => [
'content-type' => 'application/json',
],
]);
echo $response->getBody();
setUrl('{{baseUrl}}/answerInlineQuery');
$request->setMethod(HTTP_METH_POST);
$request->setHeaders([
'content-type' => 'application/json'
]);
$request->setContentType('application/json');
$request->setBody(json_encode([
'cache_time' => 0,
'inline_query_id' => '',
'is_personal' => null,
'next_offset' => '',
'results' => [
],
'switch_pm_parameter' => '',
'switch_pm_text' => ''
]));
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
append(json_encode([
'cache_time' => 0,
'inline_query_id' => '',
'is_personal' => null,
'next_offset' => '',
'results' => [
],
'switch_pm_parameter' => '',
'switch_pm_text' => ''
]));
$request->setRequestUrl('{{baseUrl}}/answerInlineQuery');
$request->setRequestMethod('POST');
$request->setBody($body);
$request->setHeaders([
'content-type' => 'application/json'
]);
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
$headers=@{}
$headers.Add("content-type", "application/json")
$response = Invoke-WebRequest -Uri '{{baseUrl}}/answerInlineQuery' -Method POST -Headers $headers -ContentType 'application/json' -Body '{
"cache_time": 0,
"inline_query_id": "",
"is_personal": false,
"next_offset": "",
"results": [],
"switch_pm_parameter": "",
"switch_pm_text": ""
}'
$headers=@{}
$headers.Add("content-type", "application/json")
$response = Invoke-RestMethod -Uri '{{baseUrl}}/answerInlineQuery' -Method POST -Headers $headers -ContentType 'application/json' -Body '{
"cache_time": 0,
"inline_query_id": "",
"is_personal": false,
"next_offset": "",
"results": [],
"switch_pm_parameter": "",
"switch_pm_text": ""
}'
import http.client
conn = http.client.HTTPSConnection("example.com")
payload = "{\n \"cache_time\": 0,\n \"inline_query_id\": \"\",\n \"is_personal\": false,\n \"next_offset\": \"\",\n \"results\": [],\n \"switch_pm_parameter\": \"\",\n \"switch_pm_text\": \"\"\n}"
headers = { 'content-type': "application/json" }
conn.request("POST", "/baseUrl/answerInlineQuery", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
import requests
url = "{{baseUrl}}/answerInlineQuery"
payload = {
"cache_time": 0,
"inline_query_id": "",
"is_personal": False,
"next_offset": "",
"results": [],
"switch_pm_parameter": "",
"switch_pm_text": ""
}
headers = {"content-type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
library(httr)
url <- "{{baseUrl}}/answerInlineQuery"
payload <- "{\n \"cache_time\": 0,\n \"inline_query_id\": \"\",\n \"is_personal\": false,\n \"next_offset\": \"\",\n \"results\": [],\n \"switch_pm_parameter\": \"\",\n \"switch_pm_text\": \"\"\n}"
encode <- "json"
response <- VERB("POST", url, body = payload, content_type("application/json"), encode = encode)
content(response, "text")
require 'uri'
require 'net/http'
url = URI("{{baseUrl}}/answerInlineQuery")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["content-type"] = 'application/json'
request.body = "{\n \"cache_time\": 0,\n \"inline_query_id\": \"\",\n \"is_personal\": false,\n \"next_offset\": \"\",\n \"results\": [],\n \"switch_pm_parameter\": \"\",\n \"switch_pm_text\": \"\"\n}"
response = http.request(request)
puts response.read_body
require 'faraday'
conn = Faraday.new(
url: 'https://example.com',
headers: {'Content-Type' => 'application/json'}
)
response = conn.post('/baseUrl/answerInlineQuery') do |req|
req.body = "{\n \"cache_time\": 0,\n \"inline_query_id\": \"\",\n \"is_personal\": false,\n \"next_offset\": \"\",\n \"results\": [],\n \"switch_pm_parameter\": \"\",\n \"switch_pm_text\": \"\"\n}"
end
puts response.status
puts response.body
use serde_json::json;
use reqwest;
#[tokio::main]
pub async fn main() {
let url = "{{baseUrl}}/answerInlineQuery";
let payload = json!({
"cache_time": 0,
"inline_query_id": "",
"is_personal": false,
"next_offset": "",
"results": (),
"switch_pm_parameter": "",
"switch_pm_text": ""
});
let mut headers = reqwest::header::HeaderMap::new();
headers.insert("content-type", "application/json".parse().unwrap());
let client = reqwest::Client::new();
let response = client.post(url)
.headers(headers)
.json(&payload)
.send()
.await;
let results = response.unwrap()
.json::()
.await
.unwrap();
dbg!(results);
}
curl --request POST \
--url {{baseUrl}}/answerInlineQuery \
--header 'content-type: application/json' \
--data '{
"cache_time": 0,
"inline_query_id": "",
"is_personal": false,
"next_offset": "",
"results": [],
"switch_pm_parameter": "",
"switch_pm_text": ""
}'
echo '{
"cache_time": 0,
"inline_query_id": "",
"is_personal": false,
"next_offset": "",
"results": [],
"switch_pm_parameter": "",
"switch_pm_text": ""
}' | \
http POST {{baseUrl}}/answerInlineQuery \
content-type:application/json
wget --quiet \
--method POST \
--header 'content-type: application/json' \
--body-data '{\n "cache_time": 0,\n "inline_query_id": "",\n "is_personal": false,\n "next_offset": "",\n "results": [],\n "switch_pm_parameter": "",\n "switch_pm_text": ""\n}' \
--output-document \
- {{baseUrl}}/answerInlineQuery
import Foundation
let headers = ["content-type": "application/json"]
let parameters = [
"cache_time": 0,
"inline_query_id": "",
"is_personal": false,
"next_offset": "",
"results": [],
"switch_pm_parameter": "",
"switch_pm_text": ""
] as [String : Any]
let postData = JSONSerialization.data(withJSONObject: parameters, options: [])
let request = NSMutableURLRequest(url: NSURL(string: "{{baseUrl}}/answerInlineQuery")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error as Any)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
POST
Use this method to send general files. On success, the sent [Message](https---core.telegram.org-bots-api-#message) is returned. Bots can currently send files of any type of up to 50 MB in size, this limit may be changed in the future.
{{baseUrl}}/sendDocument
BODY multipartForm
Examples
REQUEST
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(hnd, CURLOPT_URL, "{{baseUrl}}/sendDocument");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "content-type: multipart/form-data; boundary=---011000010111000001101001");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"allow_sending_without_reply\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"caption\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"caption_entities\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"chat_id\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"disable_content_type_detection\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"disable_notification\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"document\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"parse_mode\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"reply_markup\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"reply_to_message_id\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"thumb\"\r\n\r\n\r\n-----011000010111000001101001--\r\n");
CURLcode ret = curl_easy_perform(hnd);
(require '[clj-http.client :as client])
(client/post "{{baseUrl}}/sendDocument" {:multipart [{:name "allow_sending_without_reply"
:content ""} {:name "caption"
:content ""} {:name "caption_entities"
:content ""} {:name "chat_id"
:content ""} {:name "disable_content_type_detection"
:content ""} {:name "disable_notification"
:content ""} {:name "document"
:content ""} {:name "parse_mode"
:content ""} {:name "reply_markup"
:content ""} {:name "reply_to_message_id"
:content ""} {:name "thumb"
:content ""}]})
require "http/client"
url = "{{baseUrl}}/sendDocument"
headers = HTTP::Headers{
"content-type" => "multipart/form-data; boundary=---011000010111000001101001"
}
reqBody = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"allow_sending_without_reply\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"caption\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"caption_entities\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"chat_id\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"disable_content_type_detection\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"disable_notification\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"document\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"parse_mode\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"reply_markup\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"reply_to_message_id\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"thumb\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"
response = HTTP::Client.post url, headers: headers, body: reqBody
puts response.body
using System.Net.Http.Headers;
var client = new HttpClient();
var request = new HttpRequestMessage
{
Method = HttpMethod.Post,
RequestUri = new Uri("{{baseUrl}}/sendDocument"),
Content = new MultipartFormDataContent
{
new StringContent("")
{
Headers =
{
ContentDisposition = new ContentDispositionHeaderValue("form-data")
{
Name = "allow_sending_without_reply",
}
}
},
new StringContent("")
{
Headers =
{
ContentDisposition = new ContentDispositionHeaderValue("form-data")
{
Name = "caption",
}
}
},
new StringContent("")
{
Headers =
{
ContentDisposition = new ContentDispositionHeaderValue("form-data")
{
Name = "caption_entities",
}
}
},
new StringContent("")
{
Headers =
{
ContentDisposition = new ContentDispositionHeaderValue("form-data")
{
Name = "chat_id",
}
}
},
new StringContent("")
{
Headers =
{
ContentDisposition = new ContentDispositionHeaderValue("form-data")
{
Name = "disable_content_type_detection",
}
}
},
new StringContent("")
{
Headers =
{
ContentDisposition = new ContentDispositionHeaderValue("form-data")
{
Name = "disable_notification",
}
}
},
new StringContent("")
{
Headers =
{
ContentDisposition = new ContentDispositionHeaderValue("form-data")
{
Name = "document",
}
}
},
new StringContent("")
{
Headers =
{
ContentDisposition = new ContentDispositionHeaderValue("form-data")
{
Name = "parse_mode",
}
}
},
new StringContent("")
{
Headers =
{
ContentDisposition = new ContentDispositionHeaderValue("form-data")
{
Name = "reply_markup",
}
}
},
new StringContent("")
{
Headers =
{
ContentDisposition = new ContentDispositionHeaderValue("form-data")
{
Name = "reply_to_message_id",
}
}
},
new StringContent("")
{
Headers =
{
ContentDisposition = new ContentDispositionHeaderValue("form-data")
{
Name = "thumb",
}
}
},
},
};
using (var response = await client.SendAsync(request))
{
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
}
var client = new RestClient("{{baseUrl}}/sendDocument");
var request = new RestRequest("", Method.Post);
request.AddHeader("content-type", "multipart/form-data; boundary=---011000010111000001101001");
request.AddParameter("multipart/form-data; boundary=---011000010111000001101001", "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"allow_sending_without_reply\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"caption\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"caption_entities\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"chat_id\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"disable_content_type_detection\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"disable_notification\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"document\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"parse_mode\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"reply_markup\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"reply_to_message_id\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"thumb\"\r\n\r\n\r\n-----011000010111000001101001--\r\n", ParameterType.RequestBody);
var response = client.Execute(request);
package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "{{baseUrl}}/sendDocument"
payload := strings.NewReader("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"allow_sending_without_reply\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"caption\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"caption_entities\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"chat_id\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"disable_content_type_detection\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"disable_notification\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"document\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"parse_mode\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"reply_markup\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"reply_to_message_id\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"thumb\"\r\n\r\n\r\n-----011000010111000001101001--\r\n")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("content-type", "multipart/form-data; boundary=---011000010111000001101001")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
POST /baseUrl/sendDocument HTTP/1.1
Content-Type: multipart/form-data; boundary=---011000010111000001101001
Host: example.com
Content-Length: 1030
-----011000010111000001101001
Content-Disposition: form-data; name="allow_sending_without_reply"
-----011000010111000001101001
Content-Disposition: form-data; name="caption"
-----011000010111000001101001
Content-Disposition: form-data; name="caption_entities"
-----011000010111000001101001
Content-Disposition: form-data; name="chat_id"
-----011000010111000001101001
Content-Disposition: form-data; name="disable_content_type_detection"
-----011000010111000001101001
Content-Disposition: form-data; name="disable_notification"
-----011000010111000001101001
Content-Disposition: form-data; name="document"
-----011000010111000001101001
Content-Disposition: form-data; name="parse_mode"
-----011000010111000001101001
Content-Disposition: form-data; name="reply_markup"
-----011000010111000001101001
Content-Disposition: form-data; name="reply_to_message_id"
-----011000010111000001101001
Content-Disposition: form-data; name="thumb"
-----011000010111000001101001--
AsyncHttpClient client = new DefaultAsyncHttpClient();
client.prepare("POST", "{{baseUrl}}/sendDocument")
.setHeader("content-type", "multipart/form-data; boundary=---011000010111000001101001")
.setBody("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"allow_sending_without_reply\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"caption\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"caption_entities\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"chat_id\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"disable_content_type_detection\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"disable_notification\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"document\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"parse_mode\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"reply_markup\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"reply_to_message_id\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"thumb\"\r\n\r\n\r\n-----011000010111000001101001--\r\n")
.execute()
.toCompletableFuture()
.thenAccept(System.out::println)
.join();
client.close();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("{{baseUrl}}/sendDocument"))
.header("content-type", "multipart/form-data; boundary=---011000010111000001101001")
.method("POST", HttpRequest.BodyPublishers.ofString("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"allow_sending_without_reply\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"caption\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"caption_entities\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"chat_id\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"disable_content_type_detection\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"disable_notification\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"document\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"parse_mode\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"reply_markup\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"reply_to_message_id\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"thumb\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"))
.build();
HttpResponse response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("multipart/form-data; boundary=---011000010111000001101001");
RequestBody body = RequestBody.create(mediaType, "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"allow_sending_without_reply\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"caption\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"caption_entities\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"chat_id\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"disable_content_type_detection\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"disable_notification\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"document\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"parse_mode\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"reply_markup\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"reply_to_message_id\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"thumb\"\r\n\r\n\r\n-----011000010111000001101001--\r\n");
Request request = new Request.Builder()
.url("{{baseUrl}}/sendDocument")
.post(body)
.addHeader("content-type", "multipart/form-data; boundary=---011000010111000001101001")
.build();
Response response = client.newCall(request).execute();
HttpResponse response = Unirest.post("{{baseUrl}}/sendDocument")
.header("content-type", "multipart/form-data; boundary=---011000010111000001101001")
.body("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"allow_sending_without_reply\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"caption\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"caption_entities\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"chat_id\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"disable_content_type_detection\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"disable_notification\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"document\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"parse_mode\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"reply_markup\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"reply_to_message_id\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"thumb\"\r\n\r\n\r\n-----011000010111000001101001--\r\n")
.asString();
const data = new FormData();
data.append('allow_sending_without_reply', '');
data.append('caption', '');
data.append('caption_entities', '');
data.append('chat_id', '');
data.append('disable_content_type_detection', '');
data.append('disable_notification', '');
data.append('document', '');
data.append('parse_mode', '');
data.append('reply_markup', '');
data.append('reply_to_message_id', '');
data.append('thumb', '');
const xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener('readystatechange', function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open('POST', '{{baseUrl}}/sendDocument');
xhr.send(data);
import axios from 'axios';
const form = new FormData();
form.append('allow_sending_without_reply', '');
form.append('caption', '');
form.append('caption_entities', '');
form.append('chat_id', '');
form.append('disable_content_type_detection', '');
form.append('disable_notification', '');
form.append('document', '');
form.append('parse_mode', '');
form.append('reply_markup', '');
form.append('reply_to_message_id', '');
form.append('thumb', '');
const options = {
method: 'POST',
url: '{{baseUrl}}/sendDocument',
headers: {'content-type': 'multipart/form-data; boundary=---011000010111000001101001'},
data: '[form]'
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const url = '{{baseUrl}}/sendDocument';
const form = new FormData();
form.append('allow_sending_without_reply', '');
form.append('caption', '');
form.append('caption_entities', '');
form.append('chat_id', '');
form.append('disable_content_type_detection', '');
form.append('disable_notification', '');
form.append('document', '');
form.append('parse_mode', '');
form.append('reply_markup', '');
form.append('reply_to_message_id', '');
form.append('thumb', '');
const options = {method: 'POST'};
options.body = form;
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
const form = new FormData();
form.append('allow_sending_without_reply', '');
form.append('caption', '');
form.append('caption_entities', '');
form.append('chat_id', '');
form.append('disable_content_type_detection', '');
form.append('disable_notification', '');
form.append('document', '');
form.append('parse_mode', '');
form.append('reply_markup', '');
form.append('reply_to_message_id', '');
form.append('thumb', '');
const settings = {
async: true,
crossDomain: true,
url: '{{baseUrl}}/sendDocument',
method: 'POST',
headers: {},
processData: false,
contentType: false,
mimeType: 'multipart/form-data',
data: form
};
$.ajax(settings).done(function (response) {
console.log(response);
});
val client = OkHttpClient()
val mediaType = MediaType.parse("multipart/form-data; boundary=---011000010111000001101001")
val body = RequestBody.create(mediaType, "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"allow_sending_without_reply\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"caption\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"caption_entities\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"chat_id\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"disable_content_type_detection\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"disable_notification\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"document\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"parse_mode\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"reply_markup\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"reply_to_message_id\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"thumb\"\r\n\r\n\r\n-----011000010111000001101001--\r\n")
val request = Request.Builder()
.url("{{baseUrl}}/sendDocument")
.post(body)
.addHeader("content-type", "multipart/form-data; boundary=---011000010111000001101001")
.build()
val response = client.newCall(request).execute()
const http = require('https');
const options = {
method: 'POST',
hostname: 'example.com',
port: null,
path: '/baseUrl/sendDocument',
headers: {
'content-type': 'multipart/form-data; boundary=---011000010111000001101001'
}
};
const req = http.request(options, function (res) {
const chunks = [];
res.on('data', function (chunk) {
chunks.push(chunk);
});
res.on('end', function () {
const body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.write('-----011000010111000001101001\r\nContent-Disposition: form-data; name="allow_sending_without_reply"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name="caption"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name="caption_entities"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name="chat_id"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name="disable_content_type_detection"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name="disable_notification"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name="document"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name="parse_mode"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name="reply_markup"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name="reply_to_message_id"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name="thumb"\r\n\r\n\r\n-----011000010111000001101001--\r\n');
req.end();
const request = require('request');
const options = {
method: 'POST',
url: '{{baseUrl}}/sendDocument',
headers: {'content-type': 'multipart/form-data; boundary=---011000010111000001101001'},
formData: {
allow_sending_without_reply: '',
caption: '',
caption_entities: '',
chat_id: '',
disable_content_type_detection: '',
disable_notification: '',
document: '',
parse_mode: '',
reply_markup: '',
reply_to_message_id: '',
thumb: ''
}
};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
const unirest = require('unirest');
const req = unirest('POST', '{{baseUrl}}/sendDocument');
req.headers({
'content-type': 'multipart/form-data; boundary=---011000010111000001101001'
});
req.multipart([]);
req.end(function (res) {
if (res.error) throw new Error(res.error);
console.log(res.body);
});
const axios = require('axios').default;
const options = {
method: 'POST',
url: '{{baseUrl}}/sendDocument',
headers: {'content-type': 'multipart/form-data; boundary=---011000010111000001101001'},
data: '-----011000010111000001101001\r\nContent-Disposition: form-data; name="allow_sending_without_reply"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name="caption"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name="caption_entities"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name="chat_id"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name="disable_content_type_detection"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name="disable_notification"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name="document"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name="parse_mode"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name="reply_markup"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name="reply_to_message_id"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name="thumb"\r\n\r\n\r\n-----011000010111000001101001--\r\n'
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const FormData = require('form-data');
const fetch = require('node-fetch');
const formData = new FormData();
formData.append('allow_sending_without_reply', '');
formData.append('caption', '');
formData.append('caption_entities', '');
formData.append('chat_id', '');
formData.append('disable_content_type_detection', '');
formData.append('disable_notification', '');
formData.append('document', '');
formData.append('parse_mode', '');
formData.append('reply_markup', '');
formData.append('reply_to_message_id', '');
formData.append('thumb', '');
const url = '{{baseUrl}}/sendDocument';
const options = {method: 'POST'};
options.body = formData;
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
#import
NSDictionary *headers = @{ @"content-type": @"multipart/form-data; boundary=---011000010111000001101001" };
NSArray *parameters = @[ @{ @"name": @"allow_sending_without_reply", @"value": @"" },
@{ @"name": @"caption", @"value": @"" },
@{ @"name": @"caption_entities", @"value": @"" },
@{ @"name": @"chat_id", @"value": @"" },
@{ @"name": @"disable_content_type_detection", @"value": @"" },
@{ @"name": @"disable_notification", @"value": @"" },
@{ @"name": @"document", @"value": @"" },
@{ @"name": @"parse_mode", @"value": @"" },
@{ @"name": @"reply_markup", @"value": @"" },
@{ @"name": @"reply_to_message_id", @"value": @"" },
@{ @"name": @"thumb", @"value": @"" } ];
NSString *boundary = @"---011000010111000001101001";
NSError *error;
NSMutableString *body = [NSMutableString string];
for (NSDictionary *param in parameters) {
[body appendFormat:@"--%@\r\n", boundary];
if (param[@"fileName"]) {
[body appendFormat:@"Content-Disposition:form-data; name=\"%@\"; filename=\"%@\"\r\n", param[@"name"], param[@"fileName"]];
[body appendFormat:@"Content-Type: %@\r\n\r\n", param[@"contentType"]];
[body appendFormat:@"%@", [NSString stringWithContentsOfFile:param[@"fileName"] encoding:NSUTF8StringEncoding error:&error]];
if (error) {
NSLog(@"%@", error);
}
} else {
[body appendFormat:@"Content-Disposition:form-data; name=\"%@\"\r\n\r\n", param[@"name"]];
[body appendFormat:@"%@", param[@"value"]];
}
}
[body appendFormat:@"\r\n--%@--\r\n", boundary];
NSData *postData = [body dataUsingEncoding:NSUTF8StringEncoding];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"{{baseUrl}}/sendDocument"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
[request setHTTPMethod:@"POST"];
[request setAllHTTPHeaderFields:headers];
[request setHTTPBody:postData];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSLog(@"%@", httpResponse);
}
}];
[dataTask resume];
open Cohttp_lwt_unix
open Cohttp
open Lwt
let uri = Uri.of_string "{{baseUrl}}/sendDocument" in
let headers = Header.add (Header.init ()) "content-type" "multipart/form-data; boundary=---011000010111000001101001" in
let body = Cohttp_lwt_body.of_string "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"allow_sending_without_reply\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"caption\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"caption_entities\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"chat_id\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"disable_content_type_detection\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"disable_notification\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"document\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"parse_mode\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"reply_markup\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"reply_to_message_id\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"thumb\"\r\n\r\n\r\n-----011000010111000001101001--\r\n" in
Client.call ~headers ~body `POST uri
>>= fun (res, body_stream) ->
(* Do stuff with the result *)
"{{baseUrl}}/sendDocument",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"allow_sending_without_reply\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"caption\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"caption_entities\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"chat_id\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"disable_content_type_detection\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"disable_notification\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"document\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"parse_mode\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"reply_markup\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"reply_to_message_id\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"thumb\"\r\n\r\n\r\n-----011000010111000001101001--\r\n",
CURLOPT_HTTPHEADER => [
"content-type: multipart/form-data; boundary=---011000010111000001101001"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
request('POST', '{{baseUrl}}/sendDocument', [
'headers' => [
'content-type' => 'multipart/form-data; boundary=---011000010111000001101001',
],
]);
echo $response->getBody();
setUrl('{{baseUrl}}/sendDocument');
$request->setMethod(HTTP_METH_POST);
$request->setHeaders([
'content-type' => 'multipart/form-data; boundary=---011000010111000001101001'
]);
$request->setBody('-----011000010111000001101001
Content-Disposition: form-data; name="allow_sending_without_reply"
-----011000010111000001101001
Content-Disposition: form-data; name="caption"
-----011000010111000001101001
Content-Disposition: form-data; name="caption_entities"
-----011000010111000001101001
Content-Disposition: form-data; name="chat_id"
-----011000010111000001101001
Content-Disposition: form-data; name="disable_content_type_detection"
-----011000010111000001101001
Content-Disposition: form-data; name="disable_notification"
-----011000010111000001101001
Content-Disposition: form-data; name="document"
-----011000010111000001101001
Content-Disposition: form-data; name="parse_mode"
-----011000010111000001101001
Content-Disposition: form-data; name="reply_markup"
-----011000010111000001101001
Content-Disposition: form-data; name="reply_to_message_id"
-----011000010111000001101001
Content-Disposition: form-data; name="thumb"
-----011000010111000001101001--
');
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
addForm(null, null);
$request->setRequestUrl('{{baseUrl}}/sendDocument');
$request->setRequestMethod('POST');
$request->setBody($body);
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
$headers=@{}
$headers.Add("content-type", "multipart/form-data; boundary=---011000010111000001101001")
$response = Invoke-WebRequest -Uri '{{baseUrl}}/sendDocument' -Method POST -Headers $headers -ContentType 'multipart/form-data; boundary=---011000010111000001101001' -Body '-----011000010111000001101001
Content-Disposition: form-data; name="allow_sending_without_reply"
-----011000010111000001101001
Content-Disposition: form-data; name="caption"
-----011000010111000001101001
Content-Disposition: form-data; name="caption_entities"
-----011000010111000001101001
Content-Disposition: form-data; name="chat_id"
-----011000010111000001101001
Content-Disposition: form-data; name="disable_content_type_detection"
-----011000010111000001101001
Content-Disposition: form-data; name="disable_notification"
-----011000010111000001101001
Content-Disposition: form-data; name="document"
-----011000010111000001101001
Content-Disposition: form-data; name="parse_mode"
-----011000010111000001101001
Content-Disposition: form-data; name="reply_markup"
-----011000010111000001101001
Content-Disposition: form-data; name="reply_to_message_id"
-----011000010111000001101001
Content-Disposition: form-data; name="thumb"
-----011000010111000001101001--
'
$headers=@{}
$headers.Add("content-type", "multipart/form-data; boundary=---011000010111000001101001")
$response = Invoke-RestMethod -Uri '{{baseUrl}}/sendDocument' -Method POST -Headers $headers -ContentType 'multipart/form-data; boundary=---011000010111000001101001' -Body '-----011000010111000001101001
Content-Disposition: form-data; name="allow_sending_without_reply"
-----011000010111000001101001
Content-Disposition: form-data; name="caption"
-----011000010111000001101001
Content-Disposition: form-data; name="caption_entities"
-----011000010111000001101001
Content-Disposition: form-data; name="chat_id"
-----011000010111000001101001
Content-Disposition: form-data; name="disable_content_type_detection"
-----011000010111000001101001
Content-Disposition: form-data; name="disable_notification"
-----011000010111000001101001
Content-Disposition: form-data; name="document"
-----011000010111000001101001
Content-Disposition: form-data; name="parse_mode"
-----011000010111000001101001
Content-Disposition: form-data; name="reply_markup"
-----011000010111000001101001
Content-Disposition: form-data; name="reply_to_message_id"
-----011000010111000001101001
Content-Disposition: form-data; name="thumb"
-----011000010111000001101001--
'
import http.client
conn = http.client.HTTPSConnection("example.com")
payload = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"allow_sending_without_reply\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"caption\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"caption_entities\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"chat_id\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"disable_content_type_detection\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"disable_notification\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"document\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"parse_mode\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"reply_markup\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"reply_to_message_id\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"thumb\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"
headers = { 'content-type': "multipart/form-data; boundary=---011000010111000001101001" }
conn.request("POST", "/baseUrl/sendDocument", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
import requests
url = "{{baseUrl}}/sendDocument"
payload = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"allow_sending_without_reply\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"caption\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"caption_entities\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"chat_id\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"disable_content_type_detection\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"disable_notification\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"document\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"parse_mode\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"reply_markup\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"reply_to_message_id\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"thumb\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"
headers = {"content-type": "multipart/form-data; boundary=---011000010111000001101001"}
response = requests.post(url, data=payload, headers=headers)
print(response.json())
library(httr)
url <- "{{baseUrl}}/sendDocument"
payload <- "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"allow_sending_without_reply\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"caption\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"caption_entities\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"chat_id\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"disable_content_type_detection\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"disable_notification\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"document\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"parse_mode\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"reply_markup\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"reply_to_message_id\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"thumb\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"
encode <- "multipart"
response <- VERB("POST", url, body = payload, content_type("multipart/form-data"), encode = encode)
content(response, "text")
require 'uri'
require 'net/http'
url = URI("{{baseUrl}}/sendDocument")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["content-type"] = 'multipart/form-data; boundary=---011000010111000001101001'
request.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"allow_sending_without_reply\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"caption\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"caption_entities\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"chat_id\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"disable_content_type_detection\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"disable_notification\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"document\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"parse_mode\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"reply_markup\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"reply_to_message_id\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"thumb\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"
response = http.request(request)
puts response.read_body
require 'faraday'
conn = Faraday.new(
url: 'https://example.com',
headers: {'Content-Type' => 'multipart/form-data; boundary=---011000010111000001101001'}
)
response = conn.post('/baseUrl/sendDocument') do |req|
req.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"allow_sending_without_reply\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"caption\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"caption_entities\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"chat_id\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"disable_content_type_detection\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"disable_notification\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"document\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"parse_mode\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"reply_markup\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"reply_to_message_id\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"thumb\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"
end
puts response.status
puts response.body
use reqwest;
#[tokio::main]
pub async fn main() {
let url = "{{baseUrl}}/sendDocument";
let form = reqwest::multipart::Form::new()
.text("allow_sending_without_reply", "")
.text("caption", "")
.text("caption_entities", "")
.text("chat_id", "")
.text("disable_content_type_detection", "")
.text("disable_notification", "")
.text("document", "")
.text("parse_mode", "")
.text("reply_markup", "")
.text("reply_to_message_id", "")
.text("thumb", "");
let mut headers = reqwest::header::HeaderMap::new();
let client = reqwest::Client::new();
let response = client.post(url)
.multipart(form)
.headers(headers)
.send()
.await;
let results = response.unwrap()
.json::()
.await
.unwrap();
dbg!(results);
}
curl --request POST \
--url {{baseUrl}}/sendDocument \
--header 'content-type: multipart/form-data' \
--form allow_sending_without_reply= \
--form caption= \
--form caption_entities= \
--form chat_id= \
--form disable_content_type_detection= \
--form disable_notification= \
--form document= \
--form parse_mode= \
--form reply_markup= \
--form reply_to_message_id= \
--form thumb=
echo '-----011000010111000001101001
Content-Disposition: form-data; name="allow_sending_without_reply"
-----011000010111000001101001
Content-Disposition: form-data; name="caption"
-----011000010111000001101001
Content-Disposition: form-data; name="caption_entities"
-----011000010111000001101001
Content-Disposition: form-data; name="chat_id"
-----011000010111000001101001
Content-Disposition: form-data; name="disable_content_type_detection"
-----011000010111000001101001
Content-Disposition: form-data; name="disable_notification"
-----011000010111000001101001
Content-Disposition: form-data; name="document"
-----011000010111000001101001
Content-Disposition: form-data; name="parse_mode"
-----011000010111000001101001
Content-Disposition: form-data; name="reply_markup"
-----011000010111000001101001
Content-Disposition: form-data; name="reply_to_message_id"
-----011000010111000001101001
Content-Disposition: form-data; name="thumb"
-----011000010111000001101001--
' | \
http POST {{baseUrl}}/sendDocument \
content-type:'multipart/form-data; boundary=---011000010111000001101001'
wget --quiet \
--method POST \
--header 'content-type: multipart/form-data; boundary=---011000010111000001101001' \
--body-data '-----011000010111000001101001\r\nContent-Disposition: form-data; name="allow_sending_without_reply"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name="caption"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name="caption_entities"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name="chat_id"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name="disable_content_type_detection"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name="disable_notification"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name="document"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name="parse_mode"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name="reply_markup"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name="reply_to_message_id"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name="thumb"\r\n\r\n\r\n-----011000010111000001101001--\r\n' \
--output-document \
- {{baseUrl}}/sendDocument
import Foundation
let headers = ["content-type": "multipart/form-data; boundary=---011000010111000001101001"]
let parameters = [
[
"name": "allow_sending_without_reply",
"value": ""
],
[
"name": "caption",
"value": ""
],
[
"name": "caption_entities",
"value": ""
],
[
"name": "chat_id",
"value": ""
],
[
"name": "disable_content_type_detection",
"value": ""
],
[
"name": "disable_notification",
"value": ""
],
[
"name": "document",
"value": ""
],
[
"name": "parse_mode",
"value": ""
],
[
"name": "reply_markup",
"value": ""
],
[
"name": "reply_to_message_id",
"value": ""
],
[
"name": "thumb",
"value": ""
]
]
let boundary = "---011000010111000001101001"
var body = ""
var error: NSError? = nil
for param in parameters {
let paramName = param["name"]!
body += "--\(boundary)\r\n"
body += "Content-Disposition:form-data; name=\"\(paramName)\""
if let filename = param["fileName"] {
let contentType = param["content-type"]!
let fileContent = String(contentsOfFile: filename, encoding: String.Encoding.utf8)
if (error != nil) {
print(error as Any)
}
body += "; filename=\"\(filename)\"\r\n"
body += "Content-Type: \(contentType)\r\n\r\n"
body += fileContent
} else if let paramValue = param["value"] {
body += "\r\n\r\n\(paramValue)"
}
}
let request = NSMutableURLRequest(url: NSURL(string: "{{baseUrl}}/sendDocument")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error as Any)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
POST
Use this method to send information about a venue. On success, the sent [Message](https---core.telegram.org-bots-api-#message) is returned.
{{baseUrl}}/sendVenue
BODY json
{
"address": "",
"allow_sending_without_reply": false,
"chat_id": "",
"disable_notification": false,
"foursquare_id": "",
"foursquare_type": "",
"google_place_id": "",
"google_place_type": "",
"latitude": "",
"longitude": "",
"reply_markup": "",
"reply_to_message_id": 0,
"title": ""
}
Examples
REQUEST
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(hnd, CURLOPT_URL, "{{baseUrl}}/sendVenue");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "content-type: application/json");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "{\n \"address\": \"\",\n \"allow_sending_without_reply\": false,\n \"chat_id\": \"\",\n \"disable_notification\": false,\n \"foursquare_id\": \"\",\n \"foursquare_type\": \"\",\n \"google_place_id\": \"\",\n \"google_place_type\": \"\",\n \"latitude\": \"\",\n \"longitude\": \"\",\n \"reply_markup\": \"\",\n \"reply_to_message_id\": 0,\n \"title\": \"\"\n}");
CURLcode ret = curl_easy_perform(hnd);
(require '[clj-http.client :as client])
(client/post "{{baseUrl}}/sendVenue" {:content-type :json
:form-params {:address ""
:allow_sending_without_reply false
:chat_id ""
:disable_notification false
:foursquare_id ""
:foursquare_type ""
:google_place_id ""
:google_place_type ""
:latitude ""
:longitude ""
:reply_markup ""
:reply_to_message_id 0
:title ""}})
require "http/client"
url = "{{baseUrl}}/sendVenue"
headers = HTTP::Headers{
"content-type" => "application/json"
}
reqBody = "{\n \"address\": \"\",\n \"allow_sending_without_reply\": false,\n \"chat_id\": \"\",\n \"disable_notification\": false,\n \"foursquare_id\": \"\",\n \"foursquare_type\": \"\",\n \"google_place_id\": \"\",\n \"google_place_type\": \"\",\n \"latitude\": \"\",\n \"longitude\": \"\",\n \"reply_markup\": \"\",\n \"reply_to_message_id\": 0,\n \"title\": \"\"\n}"
response = HTTP::Client.post url, headers: headers, body: reqBody
puts response.body
using System.Net.Http.Headers;
var client = new HttpClient();
var request = new HttpRequestMessage
{
Method = HttpMethod.Post,
RequestUri = new Uri("{{baseUrl}}/sendVenue"),
Content = new StringContent("{\n \"address\": \"\",\n \"allow_sending_without_reply\": false,\n \"chat_id\": \"\",\n \"disable_notification\": false,\n \"foursquare_id\": \"\",\n \"foursquare_type\": \"\",\n \"google_place_id\": \"\",\n \"google_place_type\": \"\",\n \"latitude\": \"\",\n \"longitude\": \"\",\n \"reply_markup\": \"\",\n \"reply_to_message_id\": 0,\n \"title\": \"\"\n}")
{
Headers =
{
ContentType = new MediaTypeHeaderValue("application/json")
}
}
};
using (var response = await client.SendAsync(request))
{
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
}
var client = new RestClient("{{baseUrl}}/sendVenue");
var request = new RestRequest("", Method.Post);
request.AddHeader("content-type", "application/json");
request.AddParameter("application/json", "{\n \"address\": \"\",\n \"allow_sending_without_reply\": false,\n \"chat_id\": \"\",\n \"disable_notification\": false,\n \"foursquare_id\": \"\",\n \"foursquare_type\": \"\",\n \"google_place_id\": \"\",\n \"google_place_type\": \"\",\n \"latitude\": \"\",\n \"longitude\": \"\",\n \"reply_markup\": \"\",\n \"reply_to_message_id\": 0,\n \"title\": \"\"\n}", ParameterType.RequestBody);
var response = client.Execute(request);
package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "{{baseUrl}}/sendVenue"
payload := strings.NewReader("{\n \"address\": \"\",\n \"allow_sending_without_reply\": false,\n \"chat_id\": \"\",\n \"disable_notification\": false,\n \"foursquare_id\": \"\",\n \"foursquare_type\": \"\",\n \"google_place_id\": \"\",\n \"google_place_type\": \"\",\n \"latitude\": \"\",\n \"longitude\": \"\",\n \"reply_markup\": \"\",\n \"reply_to_message_id\": 0,\n \"title\": \"\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("content-type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
POST /baseUrl/sendVenue HTTP/1.1
Content-Type: application/json
Host: example.com
Content-Length: 311
{
"address": "",
"allow_sending_without_reply": false,
"chat_id": "",
"disable_notification": false,
"foursquare_id": "",
"foursquare_type": "",
"google_place_id": "",
"google_place_type": "",
"latitude": "",
"longitude": "",
"reply_markup": "",
"reply_to_message_id": 0,
"title": ""
}
AsyncHttpClient client = new DefaultAsyncHttpClient();
client.prepare("POST", "{{baseUrl}}/sendVenue")
.setHeader("content-type", "application/json")
.setBody("{\n \"address\": \"\",\n \"allow_sending_without_reply\": false,\n \"chat_id\": \"\",\n \"disable_notification\": false,\n \"foursquare_id\": \"\",\n \"foursquare_type\": \"\",\n \"google_place_id\": \"\",\n \"google_place_type\": \"\",\n \"latitude\": \"\",\n \"longitude\": \"\",\n \"reply_markup\": \"\",\n \"reply_to_message_id\": 0,\n \"title\": \"\"\n}")
.execute()
.toCompletableFuture()
.thenAccept(System.out::println)
.join();
client.close();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("{{baseUrl}}/sendVenue"))
.header("content-type", "application/json")
.method("POST", HttpRequest.BodyPublishers.ofString("{\n \"address\": \"\",\n \"allow_sending_without_reply\": false,\n \"chat_id\": \"\",\n \"disable_notification\": false,\n \"foursquare_id\": \"\",\n \"foursquare_type\": \"\",\n \"google_place_id\": \"\",\n \"google_place_type\": \"\",\n \"latitude\": \"\",\n \"longitude\": \"\",\n \"reply_markup\": \"\",\n \"reply_to_message_id\": 0,\n \"title\": \"\"\n}"))
.build();
HttpResponse response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n \"address\": \"\",\n \"allow_sending_without_reply\": false,\n \"chat_id\": \"\",\n \"disable_notification\": false,\n \"foursquare_id\": \"\",\n \"foursquare_type\": \"\",\n \"google_place_id\": \"\",\n \"google_place_type\": \"\",\n \"latitude\": \"\",\n \"longitude\": \"\",\n \"reply_markup\": \"\",\n \"reply_to_message_id\": 0,\n \"title\": \"\"\n}");
Request request = new Request.Builder()
.url("{{baseUrl}}/sendVenue")
.post(body)
.addHeader("content-type", "application/json")
.build();
Response response = client.newCall(request).execute();
HttpResponse response = Unirest.post("{{baseUrl}}/sendVenue")
.header("content-type", "application/json")
.body("{\n \"address\": \"\",\n \"allow_sending_without_reply\": false,\n \"chat_id\": \"\",\n \"disable_notification\": false,\n \"foursquare_id\": \"\",\n \"foursquare_type\": \"\",\n \"google_place_id\": \"\",\n \"google_place_type\": \"\",\n \"latitude\": \"\",\n \"longitude\": \"\",\n \"reply_markup\": \"\",\n \"reply_to_message_id\": 0,\n \"title\": \"\"\n}")
.asString();
const data = JSON.stringify({
address: '',
allow_sending_without_reply: false,
chat_id: '',
disable_notification: false,
foursquare_id: '',
foursquare_type: '',
google_place_id: '',
google_place_type: '',
latitude: '',
longitude: '',
reply_markup: '',
reply_to_message_id: 0,
title: ''
});
const xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener('readystatechange', function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open('POST', '{{baseUrl}}/sendVenue');
xhr.setRequestHeader('content-type', 'application/json');
xhr.send(data);
import axios from 'axios';
const options = {
method: 'POST',
url: '{{baseUrl}}/sendVenue',
headers: {'content-type': 'application/json'},
data: {
address: '',
allow_sending_without_reply: false,
chat_id: '',
disable_notification: false,
foursquare_id: '',
foursquare_type: '',
google_place_id: '',
google_place_type: '',
latitude: '',
longitude: '',
reply_markup: '',
reply_to_message_id: 0,
title: ''
}
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const url = '{{baseUrl}}/sendVenue';
const options = {
method: 'POST',
headers: {'content-type': 'application/json'},
body: '{"address":"","allow_sending_without_reply":false,"chat_id":"","disable_notification":false,"foursquare_id":"","foursquare_type":"","google_place_id":"","google_place_type":"","latitude":"","longitude":"","reply_markup":"","reply_to_message_id":0,"title":""}'
};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
const settings = {
async: true,
crossDomain: true,
url: '{{baseUrl}}/sendVenue',
method: 'POST',
headers: {
'content-type': 'application/json'
},
processData: false,
data: '{\n "address": "",\n "allow_sending_without_reply": false,\n "chat_id": "",\n "disable_notification": false,\n "foursquare_id": "",\n "foursquare_type": "",\n "google_place_id": "",\n "google_place_type": "",\n "latitude": "",\n "longitude": "",\n "reply_markup": "",\n "reply_to_message_id": 0,\n "title": ""\n}'
};
$.ajax(settings).done(function (response) {
console.log(response);
});
val client = OkHttpClient()
val mediaType = MediaType.parse("application/json")
val body = RequestBody.create(mediaType, "{\n \"address\": \"\",\n \"allow_sending_without_reply\": false,\n \"chat_id\": \"\",\n \"disable_notification\": false,\n \"foursquare_id\": \"\",\n \"foursquare_type\": \"\",\n \"google_place_id\": \"\",\n \"google_place_type\": \"\",\n \"latitude\": \"\",\n \"longitude\": \"\",\n \"reply_markup\": \"\",\n \"reply_to_message_id\": 0,\n \"title\": \"\"\n}")
val request = Request.Builder()
.url("{{baseUrl}}/sendVenue")
.post(body)
.addHeader("content-type", "application/json")
.build()
val response = client.newCall(request).execute()
const http = require('https');
const options = {
method: 'POST',
hostname: 'example.com',
port: null,
path: '/baseUrl/sendVenue',
headers: {
'content-type': 'application/json'
}
};
const req = http.request(options, function (res) {
const chunks = [];
res.on('data', function (chunk) {
chunks.push(chunk);
});
res.on('end', function () {
const body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.write(JSON.stringify({
address: '',
allow_sending_without_reply: false,
chat_id: '',
disable_notification: false,
foursquare_id: '',
foursquare_type: '',
google_place_id: '',
google_place_type: '',
latitude: '',
longitude: '',
reply_markup: '',
reply_to_message_id: 0,
title: ''
}));
req.end();
const request = require('request');
const options = {
method: 'POST',
url: '{{baseUrl}}/sendVenue',
headers: {'content-type': 'application/json'},
body: {
address: '',
allow_sending_without_reply: false,
chat_id: '',
disable_notification: false,
foursquare_id: '',
foursquare_type: '',
google_place_id: '',
google_place_type: '',
latitude: '',
longitude: '',
reply_markup: '',
reply_to_message_id: 0,
title: ''
},
json: true
};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
const unirest = require('unirest');
const req = unirest('POST', '{{baseUrl}}/sendVenue');
req.headers({
'content-type': 'application/json'
});
req.type('json');
req.send({
address: '',
allow_sending_without_reply: false,
chat_id: '',
disable_notification: false,
foursquare_id: '',
foursquare_type: '',
google_place_id: '',
google_place_type: '',
latitude: '',
longitude: '',
reply_markup: '',
reply_to_message_id: 0,
title: ''
});
req.end(function (res) {
if (res.error) throw new Error(res.error);
console.log(res.body);
});
const axios = require('axios').default;
const options = {
method: 'POST',
url: '{{baseUrl}}/sendVenue',
headers: {'content-type': 'application/json'},
data: {
address: '',
allow_sending_without_reply: false,
chat_id: '',
disable_notification: false,
foursquare_id: '',
foursquare_type: '',
google_place_id: '',
google_place_type: '',
latitude: '',
longitude: '',
reply_markup: '',
reply_to_message_id: 0,
title: ''
}
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const fetch = require('node-fetch');
const url = '{{baseUrl}}/sendVenue';
const options = {
method: 'POST',
headers: {'content-type': 'application/json'},
body: '{"address":"","allow_sending_without_reply":false,"chat_id":"","disable_notification":false,"foursquare_id":"","foursquare_type":"","google_place_id":"","google_place_type":"","latitude":"","longitude":"","reply_markup":"","reply_to_message_id":0,"title":""}'
};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
#import
NSDictionary *headers = @{ @"content-type": @"application/json" };
NSDictionary *parameters = @{ @"address": @"",
@"allow_sending_without_reply": @NO,
@"chat_id": @"",
@"disable_notification": @NO,
@"foursquare_id": @"",
@"foursquare_type": @"",
@"google_place_id": @"",
@"google_place_type": @"",
@"latitude": @"",
@"longitude": @"",
@"reply_markup": @"",
@"reply_to_message_id": @0,
@"title": @"" };
NSData *postData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"{{baseUrl}}/sendVenue"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
[request setHTTPMethod:@"POST"];
[request setAllHTTPHeaderFields:headers];
[request setHTTPBody:postData];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSLog(@"%@", httpResponse);
}
}];
[dataTask resume];
open Cohttp_lwt_unix
open Cohttp
open Lwt
let uri = Uri.of_string "{{baseUrl}}/sendVenue" in
let headers = Header.add (Header.init ()) "content-type" "application/json" in
let body = Cohttp_lwt_body.of_string "{\n \"address\": \"\",\n \"allow_sending_without_reply\": false,\n \"chat_id\": \"\",\n \"disable_notification\": false,\n \"foursquare_id\": \"\",\n \"foursquare_type\": \"\",\n \"google_place_id\": \"\",\n \"google_place_type\": \"\",\n \"latitude\": \"\",\n \"longitude\": \"\",\n \"reply_markup\": \"\",\n \"reply_to_message_id\": 0,\n \"title\": \"\"\n}" in
Client.call ~headers ~body `POST uri
>>= fun (res, body_stream) ->
(* Do stuff with the result *)
"{{baseUrl}}/sendVenue",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'address' => '',
'allow_sending_without_reply' => null,
'chat_id' => '',
'disable_notification' => null,
'foursquare_id' => '',
'foursquare_type' => '',
'google_place_id' => '',
'google_place_type' => '',
'latitude' => '',
'longitude' => '',
'reply_markup' => '',
'reply_to_message_id' => 0,
'title' => ''
]),
CURLOPT_HTTPHEADER => [
"content-type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
request('POST', '{{baseUrl}}/sendVenue', [
'body' => '{
"address": "",
"allow_sending_without_reply": false,
"chat_id": "",
"disable_notification": false,
"foursquare_id": "",
"foursquare_type": "",
"google_place_id": "",
"google_place_type": "",
"latitude": "",
"longitude": "",
"reply_markup": "",
"reply_to_message_id": 0,
"title": ""
}',
'headers' => [
'content-type' => 'application/json',
],
]);
echo $response->getBody();
setUrl('{{baseUrl}}/sendVenue');
$request->setMethod(HTTP_METH_POST);
$request->setHeaders([
'content-type' => 'application/json'
]);
$request->setContentType('application/json');
$request->setBody(json_encode([
'address' => '',
'allow_sending_without_reply' => null,
'chat_id' => '',
'disable_notification' => null,
'foursquare_id' => '',
'foursquare_type' => '',
'google_place_id' => '',
'google_place_type' => '',
'latitude' => '',
'longitude' => '',
'reply_markup' => '',
'reply_to_message_id' => 0,
'title' => ''
]));
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
append(json_encode([
'address' => '',
'allow_sending_without_reply' => null,
'chat_id' => '',
'disable_notification' => null,
'foursquare_id' => '',
'foursquare_type' => '',
'google_place_id' => '',
'google_place_type' => '',
'latitude' => '',
'longitude' => '',
'reply_markup' => '',
'reply_to_message_id' => 0,
'title' => ''
]));
$request->setRequestUrl('{{baseUrl}}/sendVenue');
$request->setRequestMethod('POST');
$request->setBody($body);
$request->setHeaders([
'content-type' => 'application/json'
]);
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
$headers=@{}
$headers.Add("content-type", "application/json")
$response = Invoke-WebRequest -Uri '{{baseUrl}}/sendVenue' -Method POST -Headers $headers -ContentType 'application/json' -Body '{
"address": "",
"allow_sending_without_reply": false,
"chat_id": "",
"disable_notification": false,
"foursquare_id": "",
"foursquare_type": "",
"google_place_id": "",
"google_place_type": "",
"latitude": "",
"longitude": "",
"reply_markup": "",
"reply_to_message_id": 0,
"title": ""
}'
$headers=@{}
$headers.Add("content-type", "application/json")
$response = Invoke-RestMethod -Uri '{{baseUrl}}/sendVenue' -Method POST -Headers $headers -ContentType 'application/json' -Body '{
"address": "",
"allow_sending_without_reply": false,
"chat_id": "",
"disable_notification": false,
"foursquare_id": "",
"foursquare_type": "",
"google_place_id": "",
"google_place_type": "",
"latitude": "",
"longitude": "",
"reply_markup": "",
"reply_to_message_id": 0,
"title": ""
}'
import http.client
conn = http.client.HTTPSConnection("example.com")
payload = "{\n \"address\": \"\",\n \"allow_sending_without_reply\": false,\n \"chat_id\": \"\",\n \"disable_notification\": false,\n \"foursquare_id\": \"\",\n \"foursquare_type\": \"\",\n \"google_place_id\": \"\",\n \"google_place_type\": \"\",\n \"latitude\": \"\",\n \"longitude\": \"\",\n \"reply_markup\": \"\",\n \"reply_to_message_id\": 0,\n \"title\": \"\"\n}"
headers = { 'content-type': "application/json" }
conn.request("POST", "/baseUrl/sendVenue", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
import requests
url = "{{baseUrl}}/sendVenue"
payload = {
"address": "",
"allow_sending_without_reply": False,
"chat_id": "",
"disable_notification": False,
"foursquare_id": "",
"foursquare_type": "",
"google_place_id": "",
"google_place_type": "",
"latitude": "",
"longitude": "",
"reply_markup": "",
"reply_to_message_id": 0,
"title": ""
}
headers = {"content-type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
library(httr)
url <- "{{baseUrl}}/sendVenue"
payload <- "{\n \"address\": \"\",\n \"allow_sending_without_reply\": false,\n \"chat_id\": \"\",\n \"disable_notification\": false,\n \"foursquare_id\": \"\",\n \"foursquare_type\": \"\",\n \"google_place_id\": \"\",\n \"google_place_type\": \"\",\n \"latitude\": \"\",\n \"longitude\": \"\",\n \"reply_markup\": \"\",\n \"reply_to_message_id\": 0,\n \"title\": \"\"\n}"
encode <- "json"
response <- VERB("POST", url, body = payload, content_type("application/json"), encode = encode)
content(response, "text")
require 'uri'
require 'net/http'
url = URI("{{baseUrl}}/sendVenue")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["content-type"] = 'application/json'
request.body = "{\n \"address\": \"\",\n \"allow_sending_without_reply\": false,\n \"chat_id\": \"\",\n \"disable_notification\": false,\n \"foursquare_id\": \"\",\n \"foursquare_type\": \"\",\n \"google_place_id\": \"\",\n \"google_place_type\": \"\",\n \"latitude\": \"\",\n \"longitude\": \"\",\n \"reply_markup\": \"\",\n \"reply_to_message_id\": 0,\n \"title\": \"\"\n}"
response = http.request(request)
puts response.read_body
require 'faraday'
conn = Faraday.new(
url: 'https://example.com',
headers: {'Content-Type' => 'application/json'}
)
response = conn.post('/baseUrl/sendVenue') do |req|
req.body = "{\n \"address\": \"\",\n \"allow_sending_without_reply\": false,\n \"chat_id\": \"\",\n \"disable_notification\": false,\n \"foursquare_id\": \"\",\n \"foursquare_type\": \"\",\n \"google_place_id\": \"\",\n \"google_place_type\": \"\",\n \"latitude\": \"\",\n \"longitude\": \"\",\n \"reply_markup\": \"\",\n \"reply_to_message_id\": 0,\n \"title\": \"\"\n}"
end
puts response.status
puts response.body
use serde_json::json;
use reqwest;
#[tokio::main]
pub async fn main() {
let url = "{{baseUrl}}/sendVenue";
let payload = json!({
"address": "",
"allow_sending_without_reply": false,
"chat_id": "",
"disable_notification": false,
"foursquare_id": "",
"foursquare_type": "",
"google_place_id": "",
"google_place_type": "",
"latitude": "",
"longitude": "",
"reply_markup": "",
"reply_to_message_id": 0,
"title": ""
});
let mut headers = reqwest::header::HeaderMap::new();
headers.insert("content-type", "application/json".parse().unwrap());
let client = reqwest::Client::new();
let response = client.post(url)
.headers(headers)
.json(&payload)
.send()
.await;
let results = response.unwrap()
.json::()
.await
.unwrap();
dbg!(results);
}
curl --request POST \
--url {{baseUrl}}/sendVenue \
--header 'content-type: application/json' \
--data '{
"address": "",
"allow_sending_without_reply": false,
"chat_id": "",
"disable_notification": false,
"foursquare_id": "",
"foursquare_type": "",
"google_place_id": "",
"google_place_type": "",
"latitude": "",
"longitude": "",
"reply_markup": "",
"reply_to_message_id": 0,
"title": ""
}'
echo '{
"address": "",
"allow_sending_without_reply": false,
"chat_id": "",
"disable_notification": false,
"foursquare_id": "",
"foursquare_type": "",
"google_place_id": "",
"google_place_type": "",
"latitude": "",
"longitude": "",
"reply_markup": "",
"reply_to_message_id": 0,
"title": ""
}' | \
http POST {{baseUrl}}/sendVenue \
content-type:application/json
wget --quiet \
--method POST \
--header 'content-type: application/json' \
--body-data '{\n "address": "",\n "allow_sending_without_reply": false,\n "chat_id": "",\n "disable_notification": false,\n "foursquare_id": "",\n "foursquare_type": "",\n "google_place_id": "",\n "google_place_type": "",\n "latitude": "",\n "longitude": "",\n "reply_markup": "",\n "reply_to_message_id": 0,\n "title": ""\n}' \
--output-document \
- {{baseUrl}}/sendVenue
import Foundation
let headers = ["content-type": "application/json"]
let parameters = [
"address": "",
"allow_sending_without_reply": false,
"chat_id": "",
"disable_notification": false,
"foursquare_id": "",
"foursquare_type": "",
"google_place_id": "",
"google_place_type": "",
"latitude": "",
"longitude": "",
"reply_markup": "",
"reply_to_message_id": 0,
"title": ""
] as [String : Any]
let postData = JSONSerialization.data(withJSONObject: parameters, options: [])
let request = NSMutableURLRequest(url: NSURL(string: "{{baseUrl}}/sendVenue")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error as Any)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
POST
Use this method to send invoices. On success, the sent [Message](https---core.telegram.org-bots-api-#message) is returned.
{{baseUrl}}/sendInvoice
BODY json
{
"allow_sending_without_reply": false,
"chat_id": 0,
"currency": "",
"description": "",
"disable_notification": false,
"is_flexible": false,
"need_email": false,
"need_name": false,
"need_phone_number": false,
"need_shipping_address": false,
"payload": "",
"photo_height": 0,
"photo_size": 0,
"photo_url": "",
"photo_width": 0,
"prices": [
{
"amount": 0,
"label": ""
}
],
"provider_data": "",
"provider_token": "",
"reply_markup": {
"inline_keyboard": []
},
"reply_to_message_id": 0,
"send_email_to_provider": false,
"send_phone_number_to_provider": false,
"start_parameter": "",
"title": ""
}
Examples
REQUEST
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(hnd, CURLOPT_URL, "{{baseUrl}}/sendInvoice");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "content-type: application/json");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "{\n \"allow_sending_without_reply\": false,\n \"chat_id\": 0,\n \"currency\": \"\",\n \"description\": \"\",\n \"disable_notification\": false,\n \"is_flexible\": false,\n \"need_email\": false,\n \"need_name\": false,\n \"need_phone_number\": false,\n \"need_shipping_address\": false,\n \"payload\": \"\",\n \"photo_height\": 0,\n \"photo_size\": 0,\n \"photo_url\": \"\",\n \"photo_width\": 0,\n \"prices\": [\n {\n \"amount\": 0,\n \"label\": \"\"\n }\n ],\n \"provider_data\": \"\",\n \"provider_token\": \"\",\n \"reply_markup\": {\n \"inline_keyboard\": []\n },\n \"reply_to_message_id\": 0,\n \"send_email_to_provider\": false,\n \"send_phone_number_to_provider\": false,\n \"start_parameter\": \"\",\n \"title\": \"\"\n}");
CURLcode ret = curl_easy_perform(hnd);
(require '[clj-http.client :as client])
(client/post "{{baseUrl}}/sendInvoice" {:content-type :json
:form-params {:allow_sending_without_reply false
:chat_id 0
:currency ""
:description ""
:disable_notification false
:is_flexible false
:need_email false
:need_name false
:need_phone_number false
:need_shipping_address false
:payload ""
:photo_height 0
:photo_size 0
:photo_url ""
:photo_width 0
:prices [{:amount 0
:label ""}]
:provider_data ""
:provider_token ""
:reply_markup {:inline_keyboard []}
:reply_to_message_id 0
:send_email_to_provider false
:send_phone_number_to_provider false
:start_parameter ""
:title ""}})
require "http/client"
url = "{{baseUrl}}/sendInvoice"
headers = HTTP::Headers{
"content-type" => "application/json"
}
reqBody = "{\n \"allow_sending_without_reply\": false,\n \"chat_id\": 0,\n \"currency\": \"\",\n \"description\": \"\",\n \"disable_notification\": false,\n \"is_flexible\": false,\n \"need_email\": false,\n \"need_name\": false,\n \"need_phone_number\": false,\n \"need_shipping_address\": false,\n \"payload\": \"\",\n \"photo_height\": 0,\n \"photo_size\": 0,\n \"photo_url\": \"\",\n \"photo_width\": 0,\n \"prices\": [\n {\n \"amount\": 0,\n \"label\": \"\"\n }\n ],\n \"provider_data\": \"\",\n \"provider_token\": \"\",\n \"reply_markup\": {\n \"inline_keyboard\": []\n },\n \"reply_to_message_id\": 0,\n \"send_email_to_provider\": false,\n \"send_phone_number_to_provider\": false,\n \"start_parameter\": \"\",\n \"title\": \"\"\n}"
response = HTTP::Client.post url, headers: headers, body: reqBody
puts response.body
using System.Net.Http.Headers;
var client = new HttpClient();
var request = new HttpRequestMessage
{
Method = HttpMethod.Post,
RequestUri = new Uri("{{baseUrl}}/sendInvoice"),
Content = new StringContent("{\n \"allow_sending_without_reply\": false,\n \"chat_id\": 0,\n \"currency\": \"\",\n \"description\": \"\",\n \"disable_notification\": false,\n \"is_flexible\": false,\n \"need_email\": false,\n \"need_name\": false,\n \"need_phone_number\": false,\n \"need_shipping_address\": false,\n \"payload\": \"\",\n \"photo_height\": 0,\n \"photo_size\": 0,\n \"photo_url\": \"\",\n \"photo_width\": 0,\n \"prices\": [\n {\n \"amount\": 0,\n \"label\": \"\"\n }\n ],\n \"provider_data\": \"\",\n \"provider_token\": \"\",\n \"reply_markup\": {\n \"inline_keyboard\": []\n },\n \"reply_to_message_id\": 0,\n \"send_email_to_provider\": false,\n \"send_phone_number_to_provider\": false,\n \"start_parameter\": \"\",\n \"title\": \"\"\n}")
{
Headers =
{
ContentType = new MediaTypeHeaderValue("application/json")
}
}
};
using (var response = await client.SendAsync(request))
{
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
}
var client = new RestClient("{{baseUrl}}/sendInvoice");
var request = new RestRequest("", Method.Post);
request.AddHeader("content-type", "application/json");
request.AddParameter("application/json", "{\n \"allow_sending_without_reply\": false,\n \"chat_id\": 0,\n \"currency\": \"\",\n \"description\": \"\",\n \"disable_notification\": false,\n \"is_flexible\": false,\n \"need_email\": false,\n \"need_name\": false,\n \"need_phone_number\": false,\n \"need_shipping_address\": false,\n \"payload\": \"\",\n \"photo_height\": 0,\n \"photo_size\": 0,\n \"photo_url\": \"\",\n \"photo_width\": 0,\n \"prices\": [\n {\n \"amount\": 0,\n \"label\": \"\"\n }\n ],\n \"provider_data\": \"\",\n \"provider_token\": \"\",\n \"reply_markup\": {\n \"inline_keyboard\": []\n },\n \"reply_to_message_id\": 0,\n \"send_email_to_provider\": false,\n \"send_phone_number_to_provider\": false,\n \"start_parameter\": \"\",\n \"title\": \"\"\n}", ParameterType.RequestBody);
var response = client.Execute(request);
package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "{{baseUrl}}/sendInvoice"
payload := strings.NewReader("{\n \"allow_sending_without_reply\": false,\n \"chat_id\": 0,\n \"currency\": \"\",\n \"description\": \"\",\n \"disable_notification\": false,\n \"is_flexible\": false,\n \"need_email\": false,\n \"need_name\": false,\n \"need_phone_number\": false,\n \"need_shipping_address\": false,\n \"payload\": \"\",\n \"photo_height\": 0,\n \"photo_size\": 0,\n \"photo_url\": \"\",\n \"photo_width\": 0,\n \"prices\": [\n {\n \"amount\": 0,\n \"label\": \"\"\n }\n ],\n \"provider_data\": \"\",\n \"provider_token\": \"\",\n \"reply_markup\": {\n \"inline_keyboard\": []\n },\n \"reply_to_message_id\": 0,\n \"send_email_to_provider\": false,\n \"send_phone_number_to_provider\": false,\n \"start_parameter\": \"\",\n \"title\": \"\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("content-type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
POST /baseUrl/sendInvoice HTTP/1.1
Content-Type: application/json
Host: example.com
Content-Length: 670
{
"allow_sending_without_reply": false,
"chat_id": 0,
"currency": "",
"description": "",
"disable_notification": false,
"is_flexible": false,
"need_email": false,
"need_name": false,
"need_phone_number": false,
"need_shipping_address": false,
"payload": "",
"photo_height": 0,
"photo_size": 0,
"photo_url": "",
"photo_width": 0,
"prices": [
{
"amount": 0,
"label": ""
}
],
"provider_data": "",
"provider_token": "",
"reply_markup": {
"inline_keyboard": []
},
"reply_to_message_id": 0,
"send_email_to_provider": false,
"send_phone_number_to_provider": false,
"start_parameter": "",
"title": ""
}
AsyncHttpClient client = new DefaultAsyncHttpClient();
client.prepare("POST", "{{baseUrl}}/sendInvoice")
.setHeader("content-type", "application/json")
.setBody("{\n \"allow_sending_without_reply\": false,\n \"chat_id\": 0,\n \"currency\": \"\",\n \"description\": \"\",\n \"disable_notification\": false,\n \"is_flexible\": false,\n \"need_email\": false,\n \"need_name\": false,\n \"need_phone_number\": false,\n \"need_shipping_address\": false,\n \"payload\": \"\",\n \"photo_height\": 0,\n \"photo_size\": 0,\n \"photo_url\": \"\",\n \"photo_width\": 0,\n \"prices\": [\n {\n \"amount\": 0,\n \"label\": \"\"\n }\n ],\n \"provider_data\": \"\",\n \"provider_token\": \"\",\n \"reply_markup\": {\n \"inline_keyboard\": []\n },\n \"reply_to_message_id\": 0,\n \"send_email_to_provider\": false,\n \"send_phone_number_to_provider\": false,\n \"start_parameter\": \"\",\n \"title\": \"\"\n}")
.execute()
.toCompletableFuture()
.thenAccept(System.out::println)
.join();
client.close();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("{{baseUrl}}/sendInvoice"))
.header("content-type", "application/json")
.method("POST", HttpRequest.BodyPublishers.ofString("{\n \"allow_sending_without_reply\": false,\n \"chat_id\": 0,\n \"currency\": \"\",\n \"description\": \"\",\n \"disable_notification\": false,\n \"is_flexible\": false,\n \"need_email\": false,\n \"need_name\": false,\n \"need_phone_number\": false,\n \"need_shipping_address\": false,\n \"payload\": \"\",\n \"photo_height\": 0,\n \"photo_size\": 0,\n \"photo_url\": \"\",\n \"photo_width\": 0,\n \"prices\": [\n {\n \"amount\": 0,\n \"label\": \"\"\n }\n ],\n \"provider_data\": \"\",\n \"provider_token\": \"\",\n \"reply_markup\": {\n \"inline_keyboard\": []\n },\n \"reply_to_message_id\": 0,\n \"send_email_to_provider\": false,\n \"send_phone_number_to_provider\": false,\n \"start_parameter\": \"\",\n \"title\": \"\"\n}"))
.build();
HttpResponse response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n \"allow_sending_without_reply\": false,\n \"chat_id\": 0,\n \"currency\": \"\",\n \"description\": \"\",\n \"disable_notification\": false,\n \"is_flexible\": false,\n \"need_email\": false,\n \"need_name\": false,\n \"need_phone_number\": false,\n \"need_shipping_address\": false,\n \"payload\": \"\",\n \"photo_height\": 0,\n \"photo_size\": 0,\n \"photo_url\": \"\",\n \"photo_width\": 0,\n \"prices\": [\n {\n \"amount\": 0,\n \"label\": \"\"\n }\n ],\n \"provider_data\": \"\",\n \"provider_token\": \"\",\n \"reply_markup\": {\n \"inline_keyboard\": []\n },\n \"reply_to_message_id\": 0,\n \"send_email_to_provider\": false,\n \"send_phone_number_to_provider\": false,\n \"start_parameter\": \"\",\n \"title\": \"\"\n}");
Request request = new Request.Builder()
.url("{{baseUrl}}/sendInvoice")
.post(body)
.addHeader("content-type", "application/json")
.build();
Response response = client.newCall(request).execute();
HttpResponse response = Unirest.post("{{baseUrl}}/sendInvoice")
.header("content-type", "application/json")
.body("{\n \"allow_sending_without_reply\": false,\n \"chat_id\": 0,\n \"currency\": \"\",\n \"description\": \"\",\n \"disable_notification\": false,\n \"is_flexible\": false,\n \"need_email\": false,\n \"need_name\": false,\n \"need_phone_number\": false,\n \"need_shipping_address\": false,\n \"payload\": \"\",\n \"photo_height\": 0,\n \"photo_size\": 0,\n \"photo_url\": \"\",\n \"photo_width\": 0,\n \"prices\": [\n {\n \"amount\": 0,\n \"label\": \"\"\n }\n ],\n \"provider_data\": \"\",\n \"provider_token\": \"\",\n \"reply_markup\": {\n \"inline_keyboard\": []\n },\n \"reply_to_message_id\": 0,\n \"send_email_to_provider\": false,\n \"send_phone_number_to_provider\": false,\n \"start_parameter\": \"\",\n \"title\": \"\"\n}")
.asString();
const data = JSON.stringify({
allow_sending_without_reply: false,
chat_id: 0,
currency: '',
description: '',
disable_notification: false,
is_flexible: false,
need_email: false,
need_name: false,
need_phone_number: false,
need_shipping_address: false,
payload: '',
photo_height: 0,
photo_size: 0,
photo_url: '',
photo_width: 0,
prices: [
{
amount: 0,
label: ''
}
],
provider_data: '',
provider_token: '',
reply_markup: {
inline_keyboard: []
},
reply_to_message_id: 0,
send_email_to_provider: false,
send_phone_number_to_provider: false,
start_parameter: '',
title: ''
});
const xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener('readystatechange', function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open('POST', '{{baseUrl}}/sendInvoice');
xhr.setRequestHeader('content-type', 'application/json');
xhr.send(data);
import axios from 'axios';
const options = {
method: 'POST',
url: '{{baseUrl}}/sendInvoice',
headers: {'content-type': 'application/json'},
data: {
allow_sending_without_reply: false,
chat_id: 0,
currency: '',
description: '',
disable_notification: false,
is_flexible: false,
need_email: false,
need_name: false,
need_phone_number: false,
need_shipping_address: false,
payload: '',
photo_height: 0,
photo_size: 0,
photo_url: '',
photo_width: 0,
prices: [{amount: 0, label: ''}],
provider_data: '',
provider_token: '',
reply_markup: {inline_keyboard: []},
reply_to_message_id: 0,
send_email_to_provider: false,
send_phone_number_to_provider: false,
start_parameter: '',
title: ''
}
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const url = '{{baseUrl}}/sendInvoice';
const options = {
method: 'POST',
headers: {'content-type': 'application/json'},
body: '{"allow_sending_without_reply":false,"chat_id":0,"currency":"","description":"","disable_notification":false,"is_flexible":false,"need_email":false,"need_name":false,"need_phone_number":false,"need_shipping_address":false,"payload":"","photo_height":0,"photo_size":0,"photo_url":"","photo_width":0,"prices":[{"amount":0,"label":""}],"provider_data":"","provider_token":"","reply_markup":{"inline_keyboard":[]},"reply_to_message_id":0,"send_email_to_provider":false,"send_phone_number_to_provider":false,"start_parameter":"","title":""}'
};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
const settings = {
async: true,
crossDomain: true,
url: '{{baseUrl}}/sendInvoice',
method: 'POST',
headers: {
'content-type': 'application/json'
},
processData: false,
data: '{\n "allow_sending_without_reply": false,\n "chat_id": 0,\n "currency": "",\n "description": "",\n "disable_notification": false,\n "is_flexible": false,\n "need_email": false,\n "need_name": false,\n "need_phone_number": false,\n "need_shipping_address": false,\n "payload": "",\n "photo_height": 0,\n "photo_size": 0,\n "photo_url": "",\n "photo_width": 0,\n "prices": [\n {\n "amount": 0,\n "label": ""\n }\n ],\n "provider_data": "",\n "provider_token": "",\n "reply_markup": {\n "inline_keyboard": []\n },\n "reply_to_message_id": 0,\n "send_email_to_provider": false,\n "send_phone_number_to_provider": false,\n "start_parameter": "",\n "title": ""\n}'
};
$.ajax(settings).done(function (response) {
console.log(response);
});
val client = OkHttpClient()
val mediaType = MediaType.parse("application/json")
val body = RequestBody.create(mediaType, "{\n \"allow_sending_without_reply\": false,\n \"chat_id\": 0,\n \"currency\": \"\",\n \"description\": \"\",\n \"disable_notification\": false,\n \"is_flexible\": false,\n \"need_email\": false,\n \"need_name\": false,\n \"need_phone_number\": false,\n \"need_shipping_address\": false,\n \"payload\": \"\",\n \"photo_height\": 0,\n \"photo_size\": 0,\n \"photo_url\": \"\",\n \"photo_width\": 0,\n \"prices\": [\n {\n \"amount\": 0,\n \"label\": \"\"\n }\n ],\n \"provider_data\": \"\",\n \"provider_token\": \"\",\n \"reply_markup\": {\n \"inline_keyboard\": []\n },\n \"reply_to_message_id\": 0,\n \"send_email_to_provider\": false,\n \"send_phone_number_to_provider\": false,\n \"start_parameter\": \"\",\n \"title\": \"\"\n}")
val request = Request.Builder()
.url("{{baseUrl}}/sendInvoice")
.post(body)
.addHeader("content-type", "application/json")
.build()
val response = client.newCall(request).execute()
const http = require('https');
const options = {
method: 'POST',
hostname: 'example.com',
port: null,
path: '/baseUrl/sendInvoice',
headers: {
'content-type': 'application/json'
}
};
const req = http.request(options, function (res) {
const chunks = [];
res.on('data', function (chunk) {
chunks.push(chunk);
});
res.on('end', function () {
const body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.write(JSON.stringify({
allow_sending_without_reply: false,
chat_id: 0,
currency: '',
description: '',
disable_notification: false,
is_flexible: false,
need_email: false,
need_name: false,
need_phone_number: false,
need_shipping_address: false,
payload: '',
photo_height: 0,
photo_size: 0,
photo_url: '',
photo_width: 0,
prices: [{amount: 0, label: ''}],
provider_data: '',
provider_token: '',
reply_markup: {inline_keyboard: []},
reply_to_message_id: 0,
send_email_to_provider: false,
send_phone_number_to_provider: false,
start_parameter: '',
title: ''
}));
req.end();
const request = require('request');
const options = {
method: 'POST',
url: '{{baseUrl}}/sendInvoice',
headers: {'content-type': 'application/json'},
body: {
allow_sending_without_reply: false,
chat_id: 0,
currency: '',
description: '',
disable_notification: false,
is_flexible: false,
need_email: false,
need_name: false,
need_phone_number: false,
need_shipping_address: false,
payload: '',
photo_height: 0,
photo_size: 0,
photo_url: '',
photo_width: 0,
prices: [{amount: 0, label: ''}],
provider_data: '',
provider_token: '',
reply_markup: {inline_keyboard: []},
reply_to_message_id: 0,
send_email_to_provider: false,
send_phone_number_to_provider: false,
start_parameter: '',
title: ''
},
json: true
};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
const unirest = require('unirest');
const req = unirest('POST', '{{baseUrl}}/sendInvoice');
req.headers({
'content-type': 'application/json'
});
req.type('json');
req.send({
allow_sending_without_reply: false,
chat_id: 0,
currency: '',
description: '',
disable_notification: false,
is_flexible: false,
need_email: false,
need_name: false,
need_phone_number: false,
need_shipping_address: false,
payload: '',
photo_height: 0,
photo_size: 0,
photo_url: '',
photo_width: 0,
prices: [
{
amount: 0,
label: ''
}
],
provider_data: '',
provider_token: '',
reply_markup: {
inline_keyboard: []
},
reply_to_message_id: 0,
send_email_to_provider: false,
send_phone_number_to_provider: false,
start_parameter: '',
title: ''
});
req.end(function (res) {
if (res.error) throw new Error(res.error);
console.log(res.body);
});
const axios = require('axios').default;
const options = {
method: 'POST',
url: '{{baseUrl}}/sendInvoice',
headers: {'content-type': 'application/json'},
data: {
allow_sending_without_reply: false,
chat_id: 0,
currency: '',
description: '',
disable_notification: false,
is_flexible: false,
need_email: false,
need_name: false,
need_phone_number: false,
need_shipping_address: false,
payload: '',
photo_height: 0,
photo_size: 0,
photo_url: '',
photo_width: 0,
prices: [{amount: 0, label: ''}],
provider_data: '',
provider_token: '',
reply_markup: {inline_keyboard: []},
reply_to_message_id: 0,
send_email_to_provider: false,
send_phone_number_to_provider: false,
start_parameter: '',
title: ''
}
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const fetch = require('node-fetch');
const url = '{{baseUrl}}/sendInvoice';
const options = {
method: 'POST',
headers: {'content-type': 'application/json'},
body: '{"allow_sending_without_reply":false,"chat_id":0,"currency":"","description":"","disable_notification":false,"is_flexible":false,"need_email":false,"need_name":false,"need_phone_number":false,"need_shipping_address":false,"payload":"","photo_height":0,"photo_size":0,"photo_url":"","photo_width":0,"prices":[{"amount":0,"label":""}],"provider_data":"","provider_token":"","reply_markup":{"inline_keyboard":[]},"reply_to_message_id":0,"send_email_to_provider":false,"send_phone_number_to_provider":false,"start_parameter":"","title":""}'
};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
#import
NSDictionary *headers = @{ @"content-type": @"application/json" };
NSDictionary *parameters = @{ @"allow_sending_without_reply": @NO,
@"chat_id": @0,
@"currency": @"",
@"description": @"",
@"disable_notification": @NO,
@"is_flexible": @NO,
@"need_email": @NO,
@"need_name": @NO,
@"need_phone_number": @NO,
@"need_shipping_address": @NO,
@"payload": @"",
@"photo_height": @0,
@"photo_size": @0,
@"photo_url": @"",
@"photo_width": @0,
@"prices": @[ @{ @"amount": @0, @"label": @"" } ],
@"provider_data": @"",
@"provider_token": @"",
@"reply_markup": @{ @"inline_keyboard": @[ ] },
@"reply_to_message_id": @0,
@"send_email_to_provider": @NO,
@"send_phone_number_to_provider": @NO,
@"start_parameter": @"",
@"title": @"" };
NSData *postData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"{{baseUrl}}/sendInvoice"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
[request setHTTPMethod:@"POST"];
[request setAllHTTPHeaderFields:headers];
[request setHTTPBody:postData];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSLog(@"%@", httpResponse);
}
}];
[dataTask resume];
open Cohttp_lwt_unix
open Cohttp
open Lwt
let uri = Uri.of_string "{{baseUrl}}/sendInvoice" in
let headers = Header.add (Header.init ()) "content-type" "application/json" in
let body = Cohttp_lwt_body.of_string "{\n \"allow_sending_without_reply\": false,\n \"chat_id\": 0,\n \"currency\": \"\",\n \"description\": \"\",\n \"disable_notification\": false,\n \"is_flexible\": false,\n \"need_email\": false,\n \"need_name\": false,\n \"need_phone_number\": false,\n \"need_shipping_address\": false,\n \"payload\": \"\",\n \"photo_height\": 0,\n \"photo_size\": 0,\n \"photo_url\": \"\",\n \"photo_width\": 0,\n \"prices\": [\n {\n \"amount\": 0,\n \"label\": \"\"\n }\n ],\n \"provider_data\": \"\",\n \"provider_token\": \"\",\n \"reply_markup\": {\n \"inline_keyboard\": []\n },\n \"reply_to_message_id\": 0,\n \"send_email_to_provider\": false,\n \"send_phone_number_to_provider\": false,\n \"start_parameter\": \"\",\n \"title\": \"\"\n}" in
Client.call ~headers ~body `POST uri
>>= fun (res, body_stream) ->
(* Do stuff with the result *)
"{{baseUrl}}/sendInvoice",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'allow_sending_without_reply' => null,
'chat_id' => 0,
'currency' => '',
'description' => '',
'disable_notification' => null,
'is_flexible' => null,
'need_email' => null,
'need_name' => null,
'need_phone_number' => null,
'need_shipping_address' => null,
'payload' => '',
'photo_height' => 0,
'photo_size' => 0,
'photo_url' => '',
'photo_width' => 0,
'prices' => [
[
'amount' => 0,
'label' => ''
]
],
'provider_data' => '',
'provider_token' => '',
'reply_markup' => [
'inline_keyboard' => [
]
],
'reply_to_message_id' => 0,
'send_email_to_provider' => null,
'send_phone_number_to_provider' => null,
'start_parameter' => '',
'title' => ''
]),
CURLOPT_HTTPHEADER => [
"content-type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
request('POST', '{{baseUrl}}/sendInvoice', [
'body' => '{
"allow_sending_without_reply": false,
"chat_id": 0,
"currency": "",
"description": "",
"disable_notification": false,
"is_flexible": false,
"need_email": false,
"need_name": false,
"need_phone_number": false,
"need_shipping_address": false,
"payload": "",
"photo_height": 0,
"photo_size": 0,
"photo_url": "",
"photo_width": 0,
"prices": [
{
"amount": 0,
"label": ""
}
],
"provider_data": "",
"provider_token": "",
"reply_markup": {
"inline_keyboard": []
},
"reply_to_message_id": 0,
"send_email_to_provider": false,
"send_phone_number_to_provider": false,
"start_parameter": "",
"title": ""
}',
'headers' => [
'content-type' => 'application/json',
],
]);
echo $response->getBody();
setUrl('{{baseUrl}}/sendInvoice');
$request->setMethod(HTTP_METH_POST);
$request->setHeaders([
'content-type' => 'application/json'
]);
$request->setContentType('application/json');
$request->setBody(json_encode([
'allow_sending_without_reply' => null,
'chat_id' => 0,
'currency' => '',
'description' => '',
'disable_notification' => null,
'is_flexible' => null,
'need_email' => null,
'need_name' => null,
'need_phone_number' => null,
'need_shipping_address' => null,
'payload' => '',
'photo_height' => 0,
'photo_size' => 0,
'photo_url' => '',
'photo_width' => 0,
'prices' => [
[
'amount' => 0,
'label' => ''
]
],
'provider_data' => '',
'provider_token' => '',
'reply_markup' => [
'inline_keyboard' => [
]
],
'reply_to_message_id' => 0,
'send_email_to_provider' => null,
'send_phone_number_to_provider' => null,
'start_parameter' => '',
'title' => ''
]));
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
append(json_encode([
'allow_sending_without_reply' => null,
'chat_id' => 0,
'currency' => '',
'description' => '',
'disable_notification' => null,
'is_flexible' => null,
'need_email' => null,
'need_name' => null,
'need_phone_number' => null,
'need_shipping_address' => null,
'payload' => '',
'photo_height' => 0,
'photo_size' => 0,
'photo_url' => '',
'photo_width' => 0,
'prices' => [
[
'amount' => 0,
'label' => ''
]
],
'provider_data' => '',
'provider_token' => '',
'reply_markup' => [
'inline_keyboard' => [
]
],
'reply_to_message_id' => 0,
'send_email_to_provider' => null,
'send_phone_number_to_provider' => null,
'start_parameter' => '',
'title' => ''
]));
$request->setRequestUrl('{{baseUrl}}/sendInvoice');
$request->setRequestMethod('POST');
$request->setBody($body);
$request->setHeaders([
'content-type' => 'application/json'
]);
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
$headers=@{}
$headers.Add("content-type", "application/json")
$response = Invoke-WebRequest -Uri '{{baseUrl}}/sendInvoice' -Method POST -Headers $headers -ContentType 'application/json' -Body '{
"allow_sending_without_reply": false,
"chat_id": 0,
"currency": "",
"description": "",
"disable_notification": false,
"is_flexible": false,
"need_email": false,
"need_name": false,
"need_phone_number": false,
"need_shipping_address": false,
"payload": "",
"photo_height": 0,
"photo_size": 0,
"photo_url": "",
"photo_width": 0,
"prices": [
{
"amount": 0,
"label": ""
}
],
"provider_data": "",
"provider_token": "",
"reply_markup": {
"inline_keyboard": []
},
"reply_to_message_id": 0,
"send_email_to_provider": false,
"send_phone_number_to_provider": false,
"start_parameter": "",
"title": ""
}'
$headers=@{}
$headers.Add("content-type", "application/json")
$response = Invoke-RestMethod -Uri '{{baseUrl}}/sendInvoice' -Method POST -Headers $headers -ContentType 'application/json' -Body '{
"allow_sending_without_reply": false,
"chat_id": 0,
"currency": "",
"description": "",
"disable_notification": false,
"is_flexible": false,
"need_email": false,
"need_name": false,
"need_phone_number": false,
"need_shipping_address": false,
"payload": "",
"photo_height": 0,
"photo_size": 0,
"photo_url": "",
"photo_width": 0,
"prices": [
{
"amount": 0,
"label": ""
}
],
"provider_data": "",
"provider_token": "",
"reply_markup": {
"inline_keyboard": []
},
"reply_to_message_id": 0,
"send_email_to_provider": false,
"send_phone_number_to_provider": false,
"start_parameter": "",
"title": ""
}'
import http.client
conn = http.client.HTTPSConnection("example.com")
payload = "{\n \"allow_sending_without_reply\": false,\n \"chat_id\": 0,\n \"currency\": \"\",\n \"description\": \"\",\n \"disable_notification\": false,\n \"is_flexible\": false,\n \"need_email\": false,\n \"need_name\": false,\n \"need_phone_number\": false,\n \"need_shipping_address\": false,\n \"payload\": \"\",\n \"photo_height\": 0,\n \"photo_size\": 0,\n \"photo_url\": \"\",\n \"photo_width\": 0,\n \"prices\": [\n {\n \"amount\": 0,\n \"label\": \"\"\n }\n ],\n \"provider_data\": \"\",\n \"provider_token\": \"\",\n \"reply_markup\": {\n \"inline_keyboard\": []\n },\n \"reply_to_message_id\": 0,\n \"send_email_to_provider\": false,\n \"send_phone_number_to_provider\": false,\n \"start_parameter\": \"\",\n \"title\": \"\"\n}"
headers = { 'content-type': "application/json" }
conn.request("POST", "/baseUrl/sendInvoice", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
import requests
url = "{{baseUrl}}/sendInvoice"
payload = {
"allow_sending_without_reply": False,
"chat_id": 0,
"currency": "",
"description": "",
"disable_notification": False,
"is_flexible": False,
"need_email": False,
"need_name": False,
"need_phone_number": False,
"need_shipping_address": False,
"payload": "",
"photo_height": 0,
"photo_size": 0,
"photo_url": "",
"photo_width": 0,
"prices": [
{
"amount": 0,
"label": ""
}
],
"provider_data": "",
"provider_token": "",
"reply_markup": { "inline_keyboard": [] },
"reply_to_message_id": 0,
"send_email_to_provider": False,
"send_phone_number_to_provider": False,
"start_parameter": "",
"title": ""
}
headers = {"content-type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
library(httr)
url <- "{{baseUrl}}/sendInvoice"
payload <- "{\n \"allow_sending_without_reply\": false,\n \"chat_id\": 0,\n \"currency\": \"\",\n \"description\": \"\",\n \"disable_notification\": false,\n \"is_flexible\": false,\n \"need_email\": false,\n \"need_name\": false,\n \"need_phone_number\": false,\n \"need_shipping_address\": false,\n \"payload\": \"\",\n \"photo_height\": 0,\n \"photo_size\": 0,\n \"photo_url\": \"\",\n \"photo_width\": 0,\n \"prices\": [\n {\n \"amount\": 0,\n \"label\": \"\"\n }\n ],\n \"provider_data\": \"\",\n \"provider_token\": \"\",\n \"reply_markup\": {\n \"inline_keyboard\": []\n },\n \"reply_to_message_id\": 0,\n \"send_email_to_provider\": false,\n \"send_phone_number_to_provider\": false,\n \"start_parameter\": \"\",\n \"title\": \"\"\n}"
encode <- "json"
response <- VERB("POST", url, body = payload, content_type("application/json"), encode = encode)
content(response, "text")
require 'uri'
require 'net/http'
url = URI("{{baseUrl}}/sendInvoice")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["content-type"] = 'application/json'
request.body = "{\n \"allow_sending_without_reply\": false,\n \"chat_id\": 0,\n \"currency\": \"\",\n \"description\": \"\",\n \"disable_notification\": false,\n \"is_flexible\": false,\n \"need_email\": false,\n \"need_name\": false,\n \"need_phone_number\": false,\n \"need_shipping_address\": false,\n \"payload\": \"\",\n \"photo_height\": 0,\n \"photo_size\": 0,\n \"photo_url\": \"\",\n \"photo_width\": 0,\n \"prices\": [\n {\n \"amount\": 0,\n \"label\": \"\"\n }\n ],\n \"provider_data\": \"\",\n \"provider_token\": \"\",\n \"reply_markup\": {\n \"inline_keyboard\": []\n },\n \"reply_to_message_id\": 0,\n \"send_email_to_provider\": false,\n \"send_phone_number_to_provider\": false,\n \"start_parameter\": \"\",\n \"title\": \"\"\n}"
response = http.request(request)
puts response.read_body
require 'faraday'
conn = Faraday.new(
url: 'https://example.com',
headers: {'Content-Type' => 'application/json'}
)
response = conn.post('/baseUrl/sendInvoice') do |req|
req.body = "{\n \"allow_sending_without_reply\": false,\n \"chat_id\": 0,\n \"currency\": \"\",\n \"description\": \"\",\n \"disable_notification\": false,\n \"is_flexible\": false,\n \"need_email\": false,\n \"need_name\": false,\n \"need_phone_number\": false,\n \"need_shipping_address\": false,\n \"payload\": \"\",\n \"photo_height\": 0,\n \"photo_size\": 0,\n \"photo_url\": \"\",\n \"photo_width\": 0,\n \"prices\": [\n {\n \"amount\": 0,\n \"label\": \"\"\n }\n ],\n \"provider_data\": \"\",\n \"provider_token\": \"\",\n \"reply_markup\": {\n \"inline_keyboard\": []\n },\n \"reply_to_message_id\": 0,\n \"send_email_to_provider\": false,\n \"send_phone_number_to_provider\": false,\n \"start_parameter\": \"\",\n \"title\": \"\"\n}"
end
puts response.status
puts response.body
use serde_json::json;
use reqwest;
#[tokio::main]
pub async fn main() {
let url = "{{baseUrl}}/sendInvoice";
let payload = json!({
"allow_sending_without_reply": false,
"chat_id": 0,
"currency": "",
"description": "",
"disable_notification": false,
"is_flexible": false,
"need_email": false,
"need_name": false,
"need_phone_number": false,
"need_shipping_address": false,
"payload": "",
"photo_height": 0,
"photo_size": 0,
"photo_url": "",
"photo_width": 0,
"prices": (
json!({
"amount": 0,
"label": ""
})
),
"provider_data": "",
"provider_token": "",
"reply_markup": json!({"inline_keyboard": ()}),
"reply_to_message_id": 0,
"send_email_to_provider": false,
"send_phone_number_to_provider": false,
"start_parameter": "",
"title": ""
});
let mut headers = reqwest::header::HeaderMap::new();
headers.insert("content-type", "application/json".parse().unwrap());
let client = reqwest::Client::new();
let response = client.post(url)
.headers(headers)
.json(&payload)
.send()
.await;
let results = response.unwrap()
.json::()
.await
.unwrap();
dbg!(results);
}
curl --request POST \
--url {{baseUrl}}/sendInvoice \
--header 'content-type: application/json' \
--data '{
"allow_sending_without_reply": false,
"chat_id": 0,
"currency": "",
"description": "",
"disable_notification": false,
"is_flexible": false,
"need_email": false,
"need_name": false,
"need_phone_number": false,
"need_shipping_address": false,
"payload": "",
"photo_height": 0,
"photo_size": 0,
"photo_url": "",
"photo_width": 0,
"prices": [
{
"amount": 0,
"label": ""
}
],
"provider_data": "",
"provider_token": "",
"reply_markup": {
"inline_keyboard": []
},
"reply_to_message_id": 0,
"send_email_to_provider": false,
"send_phone_number_to_provider": false,
"start_parameter": "",
"title": ""
}'
echo '{
"allow_sending_without_reply": false,
"chat_id": 0,
"currency": "",
"description": "",
"disable_notification": false,
"is_flexible": false,
"need_email": false,
"need_name": false,
"need_phone_number": false,
"need_shipping_address": false,
"payload": "",
"photo_height": 0,
"photo_size": 0,
"photo_url": "",
"photo_width": 0,
"prices": [
{
"amount": 0,
"label": ""
}
],
"provider_data": "",
"provider_token": "",
"reply_markup": {
"inline_keyboard": []
},
"reply_to_message_id": 0,
"send_email_to_provider": false,
"send_phone_number_to_provider": false,
"start_parameter": "",
"title": ""
}' | \
http POST {{baseUrl}}/sendInvoice \
content-type:application/json
wget --quiet \
--method POST \
--header 'content-type: application/json' \
--body-data '{\n "allow_sending_without_reply": false,\n "chat_id": 0,\n "currency": "",\n "description": "",\n "disable_notification": false,\n "is_flexible": false,\n "need_email": false,\n "need_name": false,\n "need_phone_number": false,\n "need_shipping_address": false,\n "payload": "",\n "photo_height": 0,\n "photo_size": 0,\n "photo_url": "",\n "photo_width": 0,\n "prices": [\n {\n "amount": 0,\n "label": ""\n }\n ],\n "provider_data": "",\n "provider_token": "",\n "reply_markup": {\n "inline_keyboard": []\n },\n "reply_to_message_id": 0,\n "send_email_to_provider": false,\n "send_phone_number_to_provider": false,\n "start_parameter": "",\n "title": ""\n}' \
--output-document \
- {{baseUrl}}/sendInvoice
import Foundation
let headers = ["content-type": "application/json"]
let parameters = [
"allow_sending_without_reply": false,
"chat_id": 0,
"currency": "",
"description": "",
"disable_notification": false,
"is_flexible": false,
"need_email": false,
"need_name": false,
"need_phone_number": false,
"need_shipping_address": false,
"payload": "",
"photo_height": 0,
"photo_size": 0,
"photo_url": "",
"photo_width": 0,
"prices": [
[
"amount": 0,
"label": ""
]
],
"provider_data": "",
"provider_token": "",
"reply_markup": ["inline_keyboard": []],
"reply_to_message_id": 0,
"send_email_to_provider": false,
"send_phone_number_to_provider": false,
"start_parameter": "",
"title": ""
] as [String : Any]
let postData = JSONSerialization.data(withJSONObject: parameters, options: [])
let request = NSMutableURLRequest(url: NSURL(string: "{{baseUrl}}/sendInvoice")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error as Any)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
POST
Use this method to send phone contacts. On success, the sent [Message](https---core.telegram.org-bots-api-#message) is returned.
{{baseUrl}}/sendContact
BODY json
{
"allow_sending_without_reply": false,
"chat_id": "",
"disable_notification": false,
"first_name": "",
"last_name": "",
"phone_number": "",
"reply_markup": "",
"reply_to_message_id": 0,
"vcard": ""
}
Examples
REQUEST
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(hnd, CURLOPT_URL, "{{baseUrl}}/sendContact");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "content-type: application/json");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "{\n \"allow_sending_without_reply\": false,\n \"chat_id\": \"\",\n \"disable_notification\": false,\n \"first_name\": \"\",\n \"last_name\": \"\",\n \"phone_number\": \"\",\n \"reply_markup\": \"\",\n \"reply_to_message_id\": 0,\n \"vcard\": \"\"\n}");
CURLcode ret = curl_easy_perform(hnd);
(require '[clj-http.client :as client])
(client/post "{{baseUrl}}/sendContact" {:content-type :json
:form-params {:allow_sending_without_reply false
:chat_id ""
:disable_notification false
:first_name ""
:last_name ""
:phone_number ""
:reply_markup ""
:reply_to_message_id 0
:vcard ""}})
require "http/client"
url = "{{baseUrl}}/sendContact"
headers = HTTP::Headers{
"content-type" => "application/json"
}
reqBody = "{\n \"allow_sending_without_reply\": false,\n \"chat_id\": \"\",\n \"disable_notification\": false,\n \"first_name\": \"\",\n \"last_name\": \"\",\n \"phone_number\": \"\",\n \"reply_markup\": \"\",\n \"reply_to_message_id\": 0,\n \"vcard\": \"\"\n}"
response = HTTP::Client.post url, headers: headers, body: reqBody
puts response.body
using System.Net.Http.Headers;
var client = new HttpClient();
var request = new HttpRequestMessage
{
Method = HttpMethod.Post,
RequestUri = new Uri("{{baseUrl}}/sendContact"),
Content = new StringContent("{\n \"allow_sending_without_reply\": false,\n \"chat_id\": \"\",\n \"disable_notification\": false,\n \"first_name\": \"\",\n \"last_name\": \"\",\n \"phone_number\": \"\",\n \"reply_markup\": \"\",\n \"reply_to_message_id\": 0,\n \"vcard\": \"\"\n}")
{
Headers =
{
ContentType = new MediaTypeHeaderValue("application/json")
}
}
};
using (var response = await client.SendAsync(request))
{
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
}
var client = new RestClient("{{baseUrl}}/sendContact");
var request = new RestRequest("", Method.Post);
request.AddHeader("content-type", "application/json");
request.AddParameter("application/json", "{\n \"allow_sending_without_reply\": false,\n \"chat_id\": \"\",\n \"disable_notification\": false,\n \"first_name\": \"\",\n \"last_name\": \"\",\n \"phone_number\": \"\",\n \"reply_markup\": \"\",\n \"reply_to_message_id\": 0,\n \"vcard\": \"\"\n}", ParameterType.RequestBody);
var response = client.Execute(request);
package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "{{baseUrl}}/sendContact"
payload := strings.NewReader("{\n \"allow_sending_without_reply\": false,\n \"chat_id\": \"\",\n \"disable_notification\": false,\n \"first_name\": \"\",\n \"last_name\": \"\",\n \"phone_number\": \"\",\n \"reply_markup\": \"\",\n \"reply_to_message_id\": 0,\n \"vcard\": \"\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("content-type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
POST /baseUrl/sendContact HTTP/1.1
Content-Type: application/json
Host: example.com
Content-Length: 218
{
"allow_sending_without_reply": false,
"chat_id": "",
"disable_notification": false,
"first_name": "",
"last_name": "",
"phone_number": "",
"reply_markup": "",
"reply_to_message_id": 0,
"vcard": ""
}
AsyncHttpClient client = new DefaultAsyncHttpClient();
client.prepare("POST", "{{baseUrl}}/sendContact")
.setHeader("content-type", "application/json")
.setBody("{\n \"allow_sending_without_reply\": false,\n \"chat_id\": \"\",\n \"disable_notification\": false,\n \"first_name\": \"\",\n \"last_name\": \"\",\n \"phone_number\": \"\",\n \"reply_markup\": \"\",\n \"reply_to_message_id\": 0,\n \"vcard\": \"\"\n}")
.execute()
.toCompletableFuture()
.thenAccept(System.out::println)
.join();
client.close();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("{{baseUrl}}/sendContact"))
.header("content-type", "application/json")
.method("POST", HttpRequest.BodyPublishers.ofString("{\n \"allow_sending_without_reply\": false,\n \"chat_id\": \"\",\n \"disable_notification\": false,\n \"first_name\": \"\",\n \"last_name\": \"\",\n \"phone_number\": \"\",\n \"reply_markup\": \"\",\n \"reply_to_message_id\": 0,\n \"vcard\": \"\"\n}"))
.build();
HttpResponse response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n \"allow_sending_without_reply\": false,\n \"chat_id\": \"\",\n \"disable_notification\": false,\n \"first_name\": \"\",\n \"last_name\": \"\",\n \"phone_number\": \"\",\n \"reply_markup\": \"\",\n \"reply_to_message_id\": 0,\n \"vcard\": \"\"\n}");
Request request = new Request.Builder()
.url("{{baseUrl}}/sendContact")
.post(body)
.addHeader("content-type", "application/json")
.build();
Response response = client.newCall(request).execute();
HttpResponse response = Unirest.post("{{baseUrl}}/sendContact")
.header("content-type", "application/json")
.body("{\n \"allow_sending_without_reply\": false,\n \"chat_id\": \"\",\n \"disable_notification\": false,\n \"first_name\": \"\",\n \"last_name\": \"\",\n \"phone_number\": \"\",\n \"reply_markup\": \"\",\n \"reply_to_message_id\": 0,\n \"vcard\": \"\"\n}")
.asString();
const data = JSON.stringify({
allow_sending_without_reply: false,
chat_id: '',
disable_notification: false,
first_name: '',
last_name: '',
phone_number: '',
reply_markup: '',
reply_to_message_id: 0,
vcard: ''
});
const xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener('readystatechange', function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open('POST', '{{baseUrl}}/sendContact');
xhr.setRequestHeader('content-type', 'application/json');
xhr.send(data);
import axios from 'axios';
const options = {
method: 'POST',
url: '{{baseUrl}}/sendContact',
headers: {'content-type': 'application/json'},
data: {
allow_sending_without_reply: false,
chat_id: '',
disable_notification: false,
first_name: '',
last_name: '',
phone_number: '',
reply_markup: '',
reply_to_message_id: 0,
vcard: ''
}
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const url = '{{baseUrl}}/sendContact';
const options = {
method: 'POST',
headers: {'content-type': 'application/json'},
body: '{"allow_sending_without_reply":false,"chat_id":"","disable_notification":false,"first_name":"","last_name":"","phone_number":"","reply_markup":"","reply_to_message_id":0,"vcard":""}'
};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
const settings = {
async: true,
crossDomain: true,
url: '{{baseUrl}}/sendContact',
method: 'POST',
headers: {
'content-type': 'application/json'
},
processData: false,
data: '{\n "allow_sending_without_reply": false,\n "chat_id": "",\n "disable_notification": false,\n "first_name": "",\n "last_name": "",\n "phone_number": "",\n "reply_markup": "",\n "reply_to_message_id": 0,\n "vcard": ""\n}'
};
$.ajax(settings).done(function (response) {
console.log(response);
});
val client = OkHttpClient()
val mediaType = MediaType.parse("application/json")
val body = RequestBody.create(mediaType, "{\n \"allow_sending_without_reply\": false,\n \"chat_id\": \"\",\n \"disable_notification\": false,\n \"first_name\": \"\",\n \"last_name\": \"\",\n \"phone_number\": \"\",\n \"reply_markup\": \"\",\n \"reply_to_message_id\": 0,\n \"vcard\": \"\"\n}")
val request = Request.Builder()
.url("{{baseUrl}}/sendContact")
.post(body)
.addHeader("content-type", "application/json")
.build()
val response = client.newCall(request).execute()
const http = require('https');
const options = {
method: 'POST',
hostname: 'example.com',
port: null,
path: '/baseUrl/sendContact',
headers: {
'content-type': 'application/json'
}
};
const req = http.request(options, function (res) {
const chunks = [];
res.on('data', function (chunk) {
chunks.push(chunk);
});
res.on('end', function () {
const body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.write(JSON.stringify({
allow_sending_without_reply: false,
chat_id: '',
disable_notification: false,
first_name: '',
last_name: '',
phone_number: '',
reply_markup: '',
reply_to_message_id: 0,
vcard: ''
}));
req.end();
const request = require('request');
const options = {
method: 'POST',
url: '{{baseUrl}}/sendContact',
headers: {'content-type': 'application/json'},
body: {
allow_sending_without_reply: false,
chat_id: '',
disable_notification: false,
first_name: '',
last_name: '',
phone_number: '',
reply_markup: '',
reply_to_message_id: 0,
vcard: ''
},
json: true
};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
const unirest = require('unirest');
const req = unirest('POST', '{{baseUrl}}/sendContact');
req.headers({
'content-type': 'application/json'
});
req.type('json');
req.send({
allow_sending_without_reply: false,
chat_id: '',
disable_notification: false,
first_name: '',
last_name: '',
phone_number: '',
reply_markup: '',
reply_to_message_id: 0,
vcard: ''
});
req.end(function (res) {
if (res.error) throw new Error(res.error);
console.log(res.body);
});
const axios = require('axios').default;
const options = {
method: 'POST',
url: '{{baseUrl}}/sendContact',
headers: {'content-type': 'application/json'},
data: {
allow_sending_without_reply: false,
chat_id: '',
disable_notification: false,
first_name: '',
last_name: '',
phone_number: '',
reply_markup: '',
reply_to_message_id: 0,
vcard: ''
}
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const fetch = require('node-fetch');
const url = '{{baseUrl}}/sendContact';
const options = {
method: 'POST',
headers: {'content-type': 'application/json'},
body: '{"allow_sending_without_reply":false,"chat_id":"","disable_notification":false,"first_name":"","last_name":"","phone_number":"","reply_markup":"","reply_to_message_id":0,"vcard":""}'
};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
#import
NSDictionary *headers = @{ @"content-type": @"application/json" };
NSDictionary *parameters = @{ @"allow_sending_without_reply": @NO,
@"chat_id": @"",
@"disable_notification": @NO,
@"first_name": @"",
@"last_name": @"",
@"phone_number": @"",
@"reply_markup": @"",
@"reply_to_message_id": @0,
@"vcard": @"" };
NSData *postData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"{{baseUrl}}/sendContact"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
[request setHTTPMethod:@"POST"];
[request setAllHTTPHeaderFields:headers];
[request setHTTPBody:postData];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSLog(@"%@", httpResponse);
}
}];
[dataTask resume];
open Cohttp_lwt_unix
open Cohttp
open Lwt
let uri = Uri.of_string "{{baseUrl}}/sendContact" in
let headers = Header.add (Header.init ()) "content-type" "application/json" in
let body = Cohttp_lwt_body.of_string "{\n \"allow_sending_without_reply\": false,\n \"chat_id\": \"\",\n \"disable_notification\": false,\n \"first_name\": \"\",\n \"last_name\": \"\",\n \"phone_number\": \"\",\n \"reply_markup\": \"\",\n \"reply_to_message_id\": 0,\n \"vcard\": \"\"\n}" in
Client.call ~headers ~body `POST uri
>>= fun (res, body_stream) ->
(* Do stuff with the result *)
"{{baseUrl}}/sendContact",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'allow_sending_without_reply' => null,
'chat_id' => '',
'disable_notification' => null,
'first_name' => '',
'last_name' => '',
'phone_number' => '',
'reply_markup' => '',
'reply_to_message_id' => 0,
'vcard' => ''
]),
CURLOPT_HTTPHEADER => [
"content-type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
request('POST', '{{baseUrl}}/sendContact', [
'body' => '{
"allow_sending_without_reply": false,
"chat_id": "",
"disable_notification": false,
"first_name": "",
"last_name": "",
"phone_number": "",
"reply_markup": "",
"reply_to_message_id": 0,
"vcard": ""
}',
'headers' => [
'content-type' => 'application/json',
],
]);
echo $response->getBody();
setUrl('{{baseUrl}}/sendContact');
$request->setMethod(HTTP_METH_POST);
$request->setHeaders([
'content-type' => 'application/json'
]);
$request->setContentType('application/json');
$request->setBody(json_encode([
'allow_sending_without_reply' => null,
'chat_id' => '',
'disable_notification' => null,
'first_name' => '',
'last_name' => '',
'phone_number' => '',
'reply_markup' => '',
'reply_to_message_id' => 0,
'vcard' => ''
]));
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
append(json_encode([
'allow_sending_without_reply' => null,
'chat_id' => '',
'disable_notification' => null,
'first_name' => '',
'last_name' => '',
'phone_number' => '',
'reply_markup' => '',
'reply_to_message_id' => 0,
'vcard' => ''
]));
$request->setRequestUrl('{{baseUrl}}/sendContact');
$request->setRequestMethod('POST');
$request->setBody($body);
$request->setHeaders([
'content-type' => 'application/json'
]);
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
$headers=@{}
$headers.Add("content-type", "application/json")
$response = Invoke-WebRequest -Uri '{{baseUrl}}/sendContact' -Method POST -Headers $headers -ContentType 'application/json' -Body '{
"allow_sending_without_reply": false,
"chat_id": "",
"disable_notification": false,
"first_name": "",
"last_name": "",
"phone_number": "",
"reply_markup": "",
"reply_to_message_id": 0,
"vcard": ""
}'
$headers=@{}
$headers.Add("content-type", "application/json")
$response = Invoke-RestMethod -Uri '{{baseUrl}}/sendContact' -Method POST -Headers $headers -ContentType 'application/json' -Body '{
"allow_sending_without_reply": false,
"chat_id": "",
"disable_notification": false,
"first_name": "",
"last_name": "",
"phone_number": "",
"reply_markup": "",
"reply_to_message_id": 0,
"vcard": ""
}'
import http.client
conn = http.client.HTTPSConnection("example.com")
payload = "{\n \"allow_sending_without_reply\": false,\n \"chat_id\": \"\",\n \"disable_notification\": false,\n \"first_name\": \"\",\n \"last_name\": \"\",\n \"phone_number\": \"\",\n \"reply_markup\": \"\",\n \"reply_to_message_id\": 0,\n \"vcard\": \"\"\n}"
headers = { 'content-type': "application/json" }
conn.request("POST", "/baseUrl/sendContact", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
import requests
url = "{{baseUrl}}/sendContact"
payload = {
"allow_sending_without_reply": False,
"chat_id": "",
"disable_notification": False,
"first_name": "",
"last_name": "",
"phone_number": "",
"reply_markup": "",
"reply_to_message_id": 0,
"vcard": ""
}
headers = {"content-type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
library(httr)
url <- "{{baseUrl}}/sendContact"
payload <- "{\n \"allow_sending_without_reply\": false,\n \"chat_id\": \"\",\n \"disable_notification\": false,\n \"first_name\": \"\",\n \"last_name\": \"\",\n \"phone_number\": \"\",\n \"reply_markup\": \"\",\n \"reply_to_message_id\": 0,\n \"vcard\": \"\"\n}"
encode <- "json"
response <- VERB("POST", url, body = payload, content_type("application/json"), encode = encode)
content(response, "text")
require 'uri'
require 'net/http'
url = URI("{{baseUrl}}/sendContact")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["content-type"] = 'application/json'
request.body = "{\n \"allow_sending_without_reply\": false,\n \"chat_id\": \"\",\n \"disable_notification\": false,\n \"first_name\": \"\",\n \"last_name\": \"\",\n \"phone_number\": \"\",\n \"reply_markup\": \"\",\n \"reply_to_message_id\": 0,\n \"vcard\": \"\"\n}"
response = http.request(request)
puts response.read_body
require 'faraday'
conn = Faraday.new(
url: 'https://example.com',
headers: {'Content-Type' => 'application/json'}
)
response = conn.post('/baseUrl/sendContact') do |req|
req.body = "{\n \"allow_sending_without_reply\": false,\n \"chat_id\": \"\",\n \"disable_notification\": false,\n \"first_name\": \"\",\n \"last_name\": \"\",\n \"phone_number\": \"\",\n \"reply_markup\": \"\",\n \"reply_to_message_id\": 0,\n \"vcard\": \"\"\n}"
end
puts response.status
puts response.body
use serde_json::json;
use reqwest;
#[tokio::main]
pub async fn main() {
let url = "{{baseUrl}}/sendContact";
let payload = json!({
"allow_sending_without_reply": false,
"chat_id": "",
"disable_notification": false,
"first_name": "",
"last_name": "",
"phone_number": "",
"reply_markup": "",
"reply_to_message_id": 0,
"vcard": ""
});
let mut headers = reqwest::header::HeaderMap::new();
headers.insert("content-type", "application/json".parse().unwrap());
let client = reqwest::Client::new();
let response = client.post(url)
.headers(headers)
.json(&payload)
.send()
.await;
let results = response.unwrap()
.json::()
.await
.unwrap();
dbg!(results);
}
curl --request POST \
--url {{baseUrl}}/sendContact \
--header 'content-type: application/json' \
--data '{
"allow_sending_without_reply": false,
"chat_id": "",
"disable_notification": false,
"first_name": "",
"last_name": "",
"phone_number": "",
"reply_markup": "",
"reply_to_message_id": 0,
"vcard": ""
}'
echo '{
"allow_sending_without_reply": false,
"chat_id": "",
"disable_notification": false,
"first_name": "",
"last_name": "",
"phone_number": "",
"reply_markup": "",
"reply_to_message_id": 0,
"vcard": ""
}' | \
http POST {{baseUrl}}/sendContact \
content-type:application/json
wget --quiet \
--method POST \
--header 'content-type: application/json' \
--body-data '{\n "allow_sending_without_reply": false,\n "chat_id": "",\n "disable_notification": false,\n "first_name": "",\n "last_name": "",\n "phone_number": "",\n "reply_markup": "",\n "reply_to_message_id": 0,\n "vcard": ""\n}' \
--output-document \
- {{baseUrl}}/sendContact
import Foundation
let headers = ["content-type": "application/json"]
let parameters = [
"allow_sending_without_reply": false,
"chat_id": "",
"disable_notification": false,
"first_name": "",
"last_name": "",
"phone_number": "",
"reply_markup": "",
"reply_to_message_id": 0,
"vcard": ""
] as [String : Any]
let postData = JSONSerialization.data(withJSONObject: parameters, options: [])
let request = NSMutableURLRequest(url: NSURL(string: "{{baseUrl}}/sendContact")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error as Any)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
POST
Use this method to send photos. On success, the sent [Message](https---core.telegram.org-bots-api-#message) is returned.
{{baseUrl}}/sendPhoto
BODY multipartForm
Examples
REQUEST
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(hnd, CURLOPT_URL, "{{baseUrl}}/sendPhoto");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "content-type: multipart/form-data; boundary=---011000010111000001101001");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"allow_sending_without_reply\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"caption\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"caption_entities\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"chat_id\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"disable_notification\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"parse_mode\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"photo\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"reply_markup\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"reply_to_message_id\"\r\n\r\n\r\n-----011000010111000001101001--\r\n");
CURLcode ret = curl_easy_perform(hnd);
(require '[clj-http.client :as client])
(client/post "{{baseUrl}}/sendPhoto" {:multipart [{:name "allow_sending_without_reply"
:content ""} {:name "caption"
:content ""} {:name "caption_entities"
:content ""} {:name "chat_id"
:content ""} {:name "disable_notification"
:content ""} {:name "parse_mode"
:content ""} {:name "photo"
:content ""} {:name "reply_markup"
:content ""} {:name "reply_to_message_id"
:content ""}]})
require "http/client"
url = "{{baseUrl}}/sendPhoto"
headers = HTTP::Headers{
"content-type" => "multipart/form-data; boundary=---011000010111000001101001"
}
reqBody = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"allow_sending_without_reply\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"caption\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"caption_entities\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"chat_id\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"disable_notification\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"parse_mode\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"photo\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"reply_markup\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"reply_to_message_id\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"
response = HTTP::Client.post url, headers: headers, body: reqBody
puts response.body
using System.Net.Http.Headers;
var client = new HttpClient();
var request = new HttpRequestMessage
{
Method = HttpMethod.Post,
RequestUri = new Uri("{{baseUrl}}/sendPhoto"),
Content = new MultipartFormDataContent
{
new StringContent("")
{
Headers =
{
ContentDisposition = new ContentDispositionHeaderValue("form-data")
{
Name = "allow_sending_without_reply",
}
}
},
new StringContent("")
{
Headers =
{
ContentDisposition = new ContentDispositionHeaderValue("form-data")
{
Name = "caption",
}
}
},
new StringContent("")
{
Headers =
{
ContentDisposition = new ContentDispositionHeaderValue("form-data")
{
Name = "caption_entities",
}
}
},
new StringContent("")
{
Headers =
{
ContentDisposition = new ContentDispositionHeaderValue("form-data")
{
Name = "chat_id",
}
}
},
new StringContent("")
{
Headers =
{
ContentDisposition = new ContentDispositionHeaderValue("form-data")
{
Name = "disable_notification",
}
}
},
new StringContent("")
{
Headers =
{
ContentDisposition = new ContentDispositionHeaderValue("form-data")
{
Name = "parse_mode",
}
}
},
new StringContent("")
{
Headers =
{
ContentDisposition = new ContentDispositionHeaderValue("form-data")
{
Name = "photo",
}
}
},
new StringContent("")
{
Headers =
{
ContentDisposition = new ContentDispositionHeaderValue("form-data")
{
Name = "reply_markup",
}
}
},
new StringContent("")
{
Headers =
{
ContentDisposition = new ContentDispositionHeaderValue("form-data")
{
Name = "reply_to_message_id",
}
}
},
},
};
using (var response = await client.SendAsync(request))
{
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
}
var client = new RestClient("{{baseUrl}}/sendPhoto");
var request = new RestRequest("", Method.Post);
request.AddHeader("content-type", "multipart/form-data; boundary=---011000010111000001101001");
request.AddParameter("multipart/form-data; boundary=---011000010111000001101001", "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"allow_sending_without_reply\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"caption\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"caption_entities\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"chat_id\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"disable_notification\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"parse_mode\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"photo\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"reply_markup\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"reply_to_message_id\"\r\n\r\n\r\n-----011000010111000001101001--\r\n", ParameterType.RequestBody);
var response = client.Execute(request);
package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "{{baseUrl}}/sendPhoto"
payload := strings.NewReader("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"allow_sending_without_reply\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"caption\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"caption_entities\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"chat_id\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"disable_notification\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"parse_mode\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"photo\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"reply_markup\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"reply_to_message_id\"\r\n\r\n\r\n-----011000010111000001101001--\r\n")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("content-type", "multipart/form-data; boundary=---011000010111000001101001")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
POST /baseUrl/sendPhoto HTTP/1.1
Content-Type: multipart/form-data; boundary=---011000010111000001101001
Host: example.com
Content-Length: 840
-----011000010111000001101001
Content-Disposition: form-data; name="allow_sending_without_reply"
-----011000010111000001101001
Content-Disposition: form-data; name="caption"
-----011000010111000001101001
Content-Disposition: form-data; name="caption_entities"
-----011000010111000001101001
Content-Disposition: form-data; name="chat_id"
-----011000010111000001101001
Content-Disposition: form-data; name="disable_notification"
-----011000010111000001101001
Content-Disposition: form-data; name="parse_mode"
-----011000010111000001101001
Content-Disposition: form-data; name="photo"
-----011000010111000001101001
Content-Disposition: form-data; name="reply_markup"
-----011000010111000001101001
Content-Disposition: form-data; name="reply_to_message_id"
-----011000010111000001101001--
AsyncHttpClient client = new DefaultAsyncHttpClient();
client.prepare("POST", "{{baseUrl}}/sendPhoto")
.setHeader("content-type", "multipart/form-data; boundary=---011000010111000001101001")
.setBody("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"allow_sending_without_reply\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"caption\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"caption_entities\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"chat_id\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"disable_notification\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"parse_mode\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"photo\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"reply_markup\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"reply_to_message_id\"\r\n\r\n\r\n-----011000010111000001101001--\r\n")
.execute()
.toCompletableFuture()
.thenAccept(System.out::println)
.join();
client.close();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("{{baseUrl}}/sendPhoto"))
.header("content-type", "multipart/form-data; boundary=---011000010111000001101001")
.method("POST", HttpRequest.BodyPublishers.ofString("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"allow_sending_without_reply\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"caption\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"caption_entities\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"chat_id\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"disable_notification\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"parse_mode\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"photo\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"reply_markup\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"reply_to_message_id\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"))
.build();
HttpResponse response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("multipart/form-data; boundary=---011000010111000001101001");
RequestBody body = RequestBody.create(mediaType, "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"allow_sending_without_reply\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"caption\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"caption_entities\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"chat_id\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"disable_notification\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"parse_mode\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"photo\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"reply_markup\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"reply_to_message_id\"\r\n\r\n\r\n-----011000010111000001101001--\r\n");
Request request = new Request.Builder()
.url("{{baseUrl}}/sendPhoto")
.post(body)
.addHeader("content-type", "multipart/form-data; boundary=---011000010111000001101001")
.build();
Response response = client.newCall(request).execute();
HttpResponse response = Unirest.post("{{baseUrl}}/sendPhoto")
.header("content-type", "multipart/form-data; boundary=---011000010111000001101001")
.body("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"allow_sending_without_reply\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"caption\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"caption_entities\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"chat_id\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"disable_notification\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"parse_mode\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"photo\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"reply_markup\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"reply_to_message_id\"\r\n\r\n\r\n-----011000010111000001101001--\r\n")
.asString();
const data = new FormData();
data.append('allow_sending_without_reply', '');
data.append('caption', '');
data.append('caption_entities', '');
data.append('chat_id', '');
data.append('disable_notification', '');
data.append('parse_mode', '');
data.append('photo', '');
data.append('reply_markup', '');
data.append('reply_to_message_id', '');
const xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener('readystatechange', function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open('POST', '{{baseUrl}}/sendPhoto');
xhr.send(data);
import axios from 'axios';
const form = new FormData();
form.append('allow_sending_without_reply', '');
form.append('caption', '');
form.append('caption_entities', '');
form.append('chat_id', '');
form.append('disable_notification', '');
form.append('parse_mode', '');
form.append('photo', '');
form.append('reply_markup', '');
form.append('reply_to_message_id', '');
const options = {
method: 'POST',
url: '{{baseUrl}}/sendPhoto',
headers: {'content-type': 'multipart/form-data; boundary=---011000010111000001101001'},
data: '[form]'
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const url = '{{baseUrl}}/sendPhoto';
const form = new FormData();
form.append('allow_sending_without_reply', '');
form.append('caption', '');
form.append('caption_entities', '');
form.append('chat_id', '');
form.append('disable_notification', '');
form.append('parse_mode', '');
form.append('photo', '');
form.append('reply_markup', '');
form.append('reply_to_message_id', '');
const options = {method: 'POST'};
options.body = form;
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
const form = new FormData();
form.append('allow_sending_without_reply', '');
form.append('caption', '');
form.append('caption_entities', '');
form.append('chat_id', '');
form.append('disable_notification', '');
form.append('parse_mode', '');
form.append('photo', '');
form.append('reply_markup', '');
form.append('reply_to_message_id', '');
const settings = {
async: true,
crossDomain: true,
url: '{{baseUrl}}/sendPhoto',
method: 'POST',
headers: {},
processData: false,
contentType: false,
mimeType: 'multipart/form-data',
data: form
};
$.ajax(settings).done(function (response) {
console.log(response);
});
val client = OkHttpClient()
val mediaType = MediaType.parse("multipart/form-data; boundary=---011000010111000001101001")
val body = RequestBody.create(mediaType, "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"allow_sending_without_reply\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"caption\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"caption_entities\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"chat_id\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"disable_notification\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"parse_mode\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"photo\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"reply_markup\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"reply_to_message_id\"\r\n\r\n\r\n-----011000010111000001101001--\r\n")
val request = Request.Builder()
.url("{{baseUrl}}/sendPhoto")
.post(body)
.addHeader("content-type", "multipart/form-data; boundary=---011000010111000001101001")
.build()
val response = client.newCall(request).execute()
const http = require('https');
const options = {
method: 'POST',
hostname: 'example.com',
port: null,
path: '/baseUrl/sendPhoto',
headers: {
'content-type': 'multipart/form-data; boundary=---011000010111000001101001'
}
};
const req = http.request(options, function (res) {
const chunks = [];
res.on('data', function (chunk) {
chunks.push(chunk);
});
res.on('end', function () {
const body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.write('-----011000010111000001101001\r\nContent-Disposition: form-data; name="allow_sending_without_reply"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name="caption"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name="caption_entities"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name="chat_id"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name="disable_notification"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name="parse_mode"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name="photo"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name="reply_markup"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name="reply_to_message_id"\r\n\r\n\r\n-----011000010111000001101001--\r\n');
req.end();
const request = require('request');
const options = {
method: 'POST',
url: '{{baseUrl}}/sendPhoto',
headers: {'content-type': 'multipart/form-data; boundary=---011000010111000001101001'},
formData: {
allow_sending_without_reply: '',
caption: '',
caption_entities: '',
chat_id: '',
disable_notification: '',
parse_mode: '',
photo: '',
reply_markup: '',
reply_to_message_id: ''
}
};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
const unirest = require('unirest');
const req = unirest('POST', '{{baseUrl}}/sendPhoto');
req.headers({
'content-type': 'multipart/form-data; boundary=---011000010111000001101001'
});
req.multipart([]);
req.end(function (res) {
if (res.error) throw new Error(res.error);
console.log(res.body);
});
const axios = require('axios').default;
const options = {
method: 'POST',
url: '{{baseUrl}}/sendPhoto',
headers: {'content-type': 'multipart/form-data; boundary=---011000010111000001101001'},
data: '-----011000010111000001101001\r\nContent-Disposition: form-data; name="allow_sending_without_reply"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name="caption"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name="caption_entities"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name="chat_id"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name="disable_notification"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name="parse_mode"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name="photo"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name="reply_markup"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name="reply_to_message_id"\r\n\r\n\r\n-----011000010111000001101001--\r\n'
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const FormData = require('form-data');
const fetch = require('node-fetch');
const formData = new FormData();
formData.append('allow_sending_without_reply', '');
formData.append('caption', '');
formData.append('caption_entities', '');
formData.append('chat_id', '');
formData.append('disable_notification', '');
formData.append('parse_mode', '');
formData.append('photo', '');
formData.append('reply_markup', '');
formData.append('reply_to_message_id', '');
const url = '{{baseUrl}}/sendPhoto';
const options = {method: 'POST'};
options.body = formData;
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
#import
NSDictionary *headers = @{ @"content-type": @"multipart/form-data; boundary=---011000010111000001101001" };
NSArray *parameters = @[ @{ @"name": @"allow_sending_without_reply", @"value": @"" },
@{ @"name": @"caption", @"value": @"" },
@{ @"name": @"caption_entities", @"value": @"" },
@{ @"name": @"chat_id", @"value": @"" },
@{ @"name": @"disable_notification", @"value": @"" },
@{ @"name": @"parse_mode", @"value": @"" },
@{ @"name": @"photo", @"value": @"" },
@{ @"name": @"reply_markup", @"value": @"" },
@{ @"name": @"reply_to_message_id", @"value": @"" } ];
NSString *boundary = @"---011000010111000001101001";
NSError *error;
NSMutableString *body = [NSMutableString string];
for (NSDictionary *param in parameters) {
[body appendFormat:@"--%@\r\n", boundary];
if (param[@"fileName"]) {
[body appendFormat:@"Content-Disposition:form-data; name=\"%@\"; filename=\"%@\"\r\n", param[@"name"], param[@"fileName"]];
[body appendFormat:@"Content-Type: %@\r\n\r\n", param[@"contentType"]];
[body appendFormat:@"%@", [NSString stringWithContentsOfFile:param[@"fileName"] encoding:NSUTF8StringEncoding error:&error]];
if (error) {
NSLog(@"%@", error);
}
} else {
[body appendFormat:@"Content-Disposition:form-data; name=\"%@\"\r\n\r\n", param[@"name"]];
[body appendFormat:@"%@", param[@"value"]];
}
}
[body appendFormat:@"\r\n--%@--\r\n", boundary];
NSData *postData = [body dataUsingEncoding:NSUTF8StringEncoding];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"{{baseUrl}}/sendPhoto"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
[request setHTTPMethod:@"POST"];
[request setAllHTTPHeaderFields:headers];
[request setHTTPBody:postData];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSLog(@"%@", httpResponse);
}
}];
[dataTask resume];
open Cohttp_lwt_unix
open Cohttp
open Lwt
let uri = Uri.of_string "{{baseUrl}}/sendPhoto" in
let headers = Header.add (Header.init ()) "content-type" "multipart/form-data; boundary=---011000010111000001101001" in
let body = Cohttp_lwt_body.of_string "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"allow_sending_without_reply\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"caption\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"caption_entities\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"chat_id\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"disable_notification\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"parse_mode\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"photo\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"reply_markup\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"reply_to_message_id\"\r\n\r\n\r\n-----011000010111000001101001--\r\n" in
Client.call ~headers ~body `POST uri
>>= fun (res, body_stream) ->
(* Do stuff with the result *)
"{{baseUrl}}/sendPhoto",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"allow_sending_without_reply\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"caption\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"caption_entities\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"chat_id\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"disable_notification\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"parse_mode\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"photo\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"reply_markup\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"reply_to_message_id\"\r\n\r\n\r\n-----011000010111000001101001--\r\n",
CURLOPT_HTTPHEADER => [
"content-type: multipart/form-data; boundary=---011000010111000001101001"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
request('POST', '{{baseUrl}}/sendPhoto', [
'headers' => [
'content-type' => 'multipart/form-data; boundary=---011000010111000001101001',
],
]);
echo $response->getBody();
setUrl('{{baseUrl}}/sendPhoto');
$request->setMethod(HTTP_METH_POST);
$request->setHeaders([
'content-type' => 'multipart/form-data; boundary=---011000010111000001101001'
]);
$request->setBody('-----011000010111000001101001
Content-Disposition: form-data; name="allow_sending_without_reply"
-----011000010111000001101001
Content-Disposition: form-data; name="caption"
-----011000010111000001101001
Content-Disposition: form-data; name="caption_entities"
-----011000010111000001101001
Content-Disposition: form-data; name="chat_id"
-----011000010111000001101001
Content-Disposition: form-data; name="disable_notification"
-----011000010111000001101001
Content-Disposition: form-data; name="parse_mode"
-----011000010111000001101001
Content-Disposition: form-data; name="photo"
-----011000010111000001101001
Content-Disposition: form-data; name="reply_markup"
-----011000010111000001101001
Content-Disposition: form-data; name="reply_to_message_id"
-----011000010111000001101001--
');
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
addForm(null, null);
$request->setRequestUrl('{{baseUrl}}/sendPhoto');
$request->setRequestMethod('POST');
$request->setBody($body);
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
$headers=@{}
$headers.Add("content-type", "multipart/form-data; boundary=---011000010111000001101001")
$response = Invoke-WebRequest -Uri '{{baseUrl}}/sendPhoto' -Method POST -Headers $headers -ContentType 'multipart/form-data; boundary=---011000010111000001101001' -Body '-----011000010111000001101001
Content-Disposition: form-data; name="allow_sending_without_reply"
-----011000010111000001101001
Content-Disposition: form-data; name="caption"
-----011000010111000001101001
Content-Disposition: form-data; name="caption_entities"
-----011000010111000001101001
Content-Disposition: form-data; name="chat_id"
-----011000010111000001101001
Content-Disposition: form-data; name="disable_notification"
-----011000010111000001101001
Content-Disposition: form-data; name="parse_mode"
-----011000010111000001101001
Content-Disposition: form-data; name="photo"
-----011000010111000001101001
Content-Disposition: form-data; name="reply_markup"
-----011000010111000001101001
Content-Disposition: form-data; name="reply_to_message_id"
-----011000010111000001101001--
'
$headers=@{}
$headers.Add("content-type", "multipart/form-data; boundary=---011000010111000001101001")
$response = Invoke-RestMethod -Uri '{{baseUrl}}/sendPhoto' -Method POST -Headers $headers -ContentType 'multipart/form-data; boundary=---011000010111000001101001' -Body '-----011000010111000001101001
Content-Disposition: form-data; name="allow_sending_without_reply"
-----011000010111000001101001
Content-Disposition: form-data; name="caption"
-----011000010111000001101001
Content-Disposition: form-data; name="caption_entities"
-----011000010111000001101001
Content-Disposition: form-data; name="chat_id"
-----011000010111000001101001
Content-Disposition: form-data; name="disable_notification"
-----011000010111000001101001
Content-Disposition: form-data; name="parse_mode"
-----011000010111000001101001
Content-Disposition: form-data; name="photo"
-----011000010111000001101001
Content-Disposition: form-data; name="reply_markup"
-----011000010111000001101001
Content-Disposition: form-data; name="reply_to_message_id"
-----011000010111000001101001--
'
import http.client
conn = http.client.HTTPSConnection("example.com")
payload = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"allow_sending_without_reply\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"caption\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"caption_entities\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"chat_id\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"disable_notification\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"parse_mode\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"photo\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"reply_markup\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"reply_to_message_id\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"
headers = { 'content-type': "multipart/form-data; boundary=---011000010111000001101001" }
conn.request("POST", "/baseUrl/sendPhoto", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
import requests
url = "{{baseUrl}}/sendPhoto"
payload = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"allow_sending_without_reply\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"caption\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"caption_entities\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"chat_id\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"disable_notification\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"parse_mode\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"photo\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"reply_markup\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"reply_to_message_id\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"
headers = {"content-type": "multipart/form-data; boundary=---011000010111000001101001"}
response = requests.post(url, data=payload, headers=headers)
print(response.json())
library(httr)
url <- "{{baseUrl}}/sendPhoto"
payload <- "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"allow_sending_without_reply\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"caption\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"caption_entities\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"chat_id\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"disable_notification\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"parse_mode\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"photo\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"reply_markup\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"reply_to_message_id\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"
encode <- "multipart"
response <- VERB("POST", url, body = payload, content_type("multipart/form-data"), encode = encode)
content(response, "text")
require 'uri'
require 'net/http'
url = URI("{{baseUrl}}/sendPhoto")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["content-type"] = 'multipart/form-data; boundary=---011000010111000001101001'
request.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"allow_sending_without_reply\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"caption\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"caption_entities\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"chat_id\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"disable_notification\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"parse_mode\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"photo\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"reply_markup\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"reply_to_message_id\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"
response = http.request(request)
puts response.read_body
require 'faraday'
conn = Faraday.new(
url: 'https://example.com',
headers: {'Content-Type' => 'multipart/form-data; boundary=---011000010111000001101001'}
)
response = conn.post('/baseUrl/sendPhoto') do |req|
req.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"allow_sending_without_reply\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"caption\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"caption_entities\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"chat_id\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"disable_notification\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"parse_mode\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"photo\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"reply_markup\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"reply_to_message_id\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"
end
puts response.status
puts response.body
use reqwest;
#[tokio::main]
pub async fn main() {
let url = "{{baseUrl}}/sendPhoto";
let form = reqwest::multipart::Form::new()
.text("allow_sending_without_reply", "")
.text("caption", "")
.text("caption_entities", "")
.text("chat_id", "")
.text("disable_notification", "")
.text("parse_mode", "")
.text("photo", "")
.text("reply_markup", "")
.text("reply_to_message_id", "");
let mut headers = reqwest::header::HeaderMap::new();
let client = reqwest::Client::new();
let response = client.post(url)
.multipart(form)
.headers(headers)
.send()
.await;
let results = response.unwrap()
.json::()
.await
.unwrap();
dbg!(results);
}
curl --request POST \
--url {{baseUrl}}/sendPhoto \
--header 'content-type: multipart/form-data' \
--form allow_sending_without_reply= \
--form caption= \
--form caption_entities= \
--form chat_id= \
--form disable_notification= \
--form parse_mode= \
--form photo= \
--form reply_markup= \
--form reply_to_message_id=
echo '-----011000010111000001101001
Content-Disposition: form-data; name="allow_sending_without_reply"
-----011000010111000001101001
Content-Disposition: form-data; name="caption"
-----011000010111000001101001
Content-Disposition: form-data; name="caption_entities"
-----011000010111000001101001
Content-Disposition: form-data; name="chat_id"
-----011000010111000001101001
Content-Disposition: form-data; name="disable_notification"
-----011000010111000001101001
Content-Disposition: form-data; name="parse_mode"
-----011000010111000001101001
Content-Disposition: form-data; name="photo"
-----011000010111000001101001
Content-Disposition: form-data; name="reply_markup"
-----011000010111000001101001
Content-Disposition: form-data; name="reply_to_message_id"
-----011000010111000001101001--
' | \
http POST {{baseUrl}}/sendPhoto \
content-type:'multipart/form-data; boundary=---011000010111000001101001'
wget --quiet \
--method POST \
--header 'content-type: multipart/form-data; boundary=---011000010111000001101001' \
--body-data '-----011000010111000001101001\r\nContent-Disposition: form-data; name="allow_sending_without_reply"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name="caption"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name="caption_entities"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name="chat_id"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name="disable_notification"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name="parse_mode"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name="photo"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name="reply_markup"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name="reply_to_message_id"\r\n\r\n\r\n-----011000010111000001101001--\r\n' \
--output-document \
- {{baseUrl}}/sendPhoto
import Foundation
let headers = ["content-type": "multipart/form-data; boundary=---011000010111000001101001"]
let parameters = [
[
"name": "allow_sending_without_reply",
"value": ""
],
[
"name": "caption",
"value": ""
],
[
"name": "caption_entities",
"value": ""
],
[
"name": "chat_id",
"value": ""
],
[
"name": "disable_notification",
"value": ""
],
[
"name": "parse_mode",
"value": ""
],
[
"name": "photo",
"value": ""
],
[
"name": "reply_markup",
"value": ""
],
[
"name": "reply_to_message_id",
"value": ""
]
]
let boundary = "---011000010111000001101001"
var body = ""
var error: NSError? = nil
for param in parameters {
let paramName = param["name"]!
body += "--\(boundary)\r\n"
body += "Content-Disposition:form-data; name=\"\(paramName)\""
if let filename = param["fileName"] {
let contentType = param["content-type"]!
let fileContent = String(contentsOfFile: filename, encoding: String.Encoding.utf8)
if (error != nil) {
print(error as Any)
}
body += "; filename=\"\(filename)\"\r\n"
body += "Content-Type: \(contentType)\r\n\r\n"
body += fileContent
} else if let paramValue = param["value"] {
body += "\r\n\r\n\(paramValue)"
}
}
let request = NSMutableURLRequest(url: NSURL(string: "{{baseUrl}}/sendPhoto")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error as Any)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
POST
Use this method to send point on the map. On success, the sent [Message](https---core.telegram.org-bots-api-#message) is returned.
{{baseUrl}}/sendLocation
BODY json
{
"allow_sending_without_reply": false,
"chat_id": "",
"disable_notification": false,
"heading": 0,
"horizontal_accuracy": "",
"latitude": "",
"live_period": 0,
"longitude": "",
"proximity_alert_radius": 0,
"reply_markup": "",
"reply_to_message_id": 0
}
Examples
REQUEST
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(hnd, CURLOPT_URL, "{{baseUrl}}/sendLocation");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "content-type: application/json");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "{\n \"allow_sending_without_reply\": false,\n \"chat_id\": \"\",\n \"disable_notification\": false,\n \"heading\": 0,\n \"horizontal_accuracy\": \"\",\n \"latitude\": \"\",\n \"live_period\": 0,\n \"longitude\": \"\",\n \"proximity_alert_radius\": 0,\n \"reply_markup\": \"\",\n \"reply_to_message_id\": 0\n}");
CURLcode ret = curl_easy_perform(hnd);
(require '[clj-http.client :as client])
(client/post "{{baseUrl}}/sendLocation" {:content-type :json
:form-params {:allow_sending_without_reply false
:chat_id ""
:disable_notification false
:heading 0
:horizontal_accuracy ""
:latitude ""
:live_period 0
:longitude ""
:proximity_alert_radius 0
:reply_markup ""
:reply_to_message_id 0}})
require "http/client"
url = "{{baseUrl}}/sendLocation"
headers = HTTP::Headers{
"content-type" => "application/json"
}
reqBody = "{\n \"allow_sending_without_reply\": false,\n \"chat_id\": \"\",\n \"disable_notification\": false,\n \"heading\": 0,\n \"horizontal_accuracy\": \"\",\n \"latitude\": \"\",\n \"live_period\": 0,\n \"longitude\": \"\",\n \"proximity_alert_radius\": 0,\n \"reply_markup\": \"\",\n \"reply_to_message_id\": 0\n}"
response = HTTP::Client.post url, headers: headers, body: reqBody
puts response.body
using System.Net.Http.Headers;
var client = new HttpClient();
var request = new HttpRequestMessage
{
Method = HttpMethod.Post,
RequestUri = new Uri("{{baseUrl}}/sendLocation"),
Content = new StringContent("{\n \"allow_sending_without_reply\": false,\n \"chat_id\": \"\",\n \"disable_notification\": false,\n \"heading\": 0,\n \"horizontal_accuracy\": \"\",\n \"latitude\": \"\",\n \"live_period\": 0,\n \"longitude\": \"\",\n \"proximity_alert_radius\": 0,\n \"reply_markup\": \"\",\n \"reply_to_message_id\": 0\n}")
{
Headers =
{
ContentType = new MediaTypeHeaderValue("application/json")
}
}
};
using (var response = await client.SendAsync(request))
{
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
}
var client = new RestClient("{{baseUrl}}/sendLocation");
var request = new RestRequest("", Method.Post);
request.AddHeader("content-type", "application/json");
request.AddParameter("application/json", "{\n \"allow_sending_without_reply\": false,\n \"chat_id\": \"\",\n \"disable_notification\": false,\n \"heading\": 0,\n \"horizontal_accuracy\": \"\",\n \"latitude\": \"\",\n \"live_period\": 0,\n \"longitude\": \"\",\n \"proximity_alert_radius\": 0,\n \"reply_markup\": \"\",\n \"reply_to_message_id\": 0\n}", ParameterType.RequestBody);
var response = client.Execute(request);
package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "{{baseUrl}}/sendLocation"
payload := strings.NewReader("{\n \"allow_sending_without_reply\": false,\n \"chat_id\": \"\",\n \"disable_notification\": false,\n \"heading\": 0,\n \"horizontal_accuracy\": \"\",\n \"latitude\": \"\",\n \"live_period\": 0,\n \"longitude\": \"\",\n \"proximity_alert_radius\": 0,\n \"reply_markup\": \"\",\n \"reply_to_message_id\": 0\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("content-type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
POST /baseUrl/sendLocation HTTP/1.1
Content-Type: application/json
Host: example.com
Content-Length: 275
{
"allow_sending_without_reply": false,
"chat_id": "",
"disable_notification": false,
"heading": 0,
"horizontal_accuracy": "",
"latitude": "",
"live_period": 0,
"longitude": "",
"proximity_alert_radius": 0,
"reply_markup": "",
"reply_to_message_id": 0
}
AsyncHttpClient client = new DefaultAsyncHttpClient();
client.prepare("POST", "{{baseUrl}}/sendLocation")
.setHeader("content-type", "application/json")
.setBody("{\n \"allow_sending_without_reply\": false,\n \"chat_id\": \"\",\n \"disable_notification\": false,\n \"heading\": 0,\n \"horizontal_accuracy\": \"\",\n \"latitude\": \"\",\n \"live_period\": 0,\n \"longitude\": \"\",\n \"proximity_alert_radius\": 0,\n \"reply_markup\": \"\",\n \"reply_to_message_id\": 0\n}")
.execute()
.toCompletableFuture()
.thenAccept(System.out::println)
.join();
client.close();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("{{baseUrl}}/sendLocation"))
.header("content-type", "application/json")
.method("POST", HttpRequest.BodyPublishers.ofString("{\n \"allow_sending_without_reply\": false,\n \"chat_id\": \"\",\n \"disable_notification\": false,\n \"heading\": 0,\n \"horizontal_accuracy\": \"\",\n \"latitude\": \"\",\n \"live_period\": 0,\n \"longitude\": \"\",\n \"proximity_alert_radius\": 0,\n \"reply_markup\": \"\",\n \"reply_to_message_id\": 0\n}"))
.build();
HttpResponse response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n \"allow_sending_without_reply\": false,\n \"chat_id\": \"\",\n \"disable_notification\": false,\n \"heading\": 0,\n \"horizontal_accuracy\": \"\",\n \"latitude\": \"\",\n \"live_period\": 0,\n \"longitude\": \"\",\n \"proximity_alert_radius\": 0,\n \"reply_markup\": \"\",\n \"reply_to_message_id\": 0\n}");
Request request = new Request.Builder()
.url("{{baseUrl}}/sendLocation")
.post(body)
.addHeader("content-type", "application/json")
.build();
Response response = client.newCall(request).execute();
HttpResponse response = Unirest.post("{{baseUrl}}/sendLocation")
.header("content-type", "application/json")
.body("{\n \"allow_sending_without_reply\": false,\n \"chat_id\": \"\",\n \"disable_notification\": false,\n \"heading\": 0,\n \"horizontal_accuracy\": \"\",\n \"latitude\": \"\",\n \"live_period\": 0,\n \"longitude\": \"\",\n \"proximity_alert_radius\": 0,\n \"reply_markup\": \"\",\n \"reply_to_message_id\": 0\n}")
.asString();
const data = JSON.stringify({
allow_sending_without_reply: false,
chat_id: '',
disable_notification: false,
heading: 0,
horizontal_accuracy: '',
latitude: '',
live_period: 0,
longitude: '',
proximity_alert_radius: 0,
reply_markup: '',
reply_to_message_id: 0
});
const xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener('readystatechange', function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open('POST', '{{baseUrl}}/sendLocation');
xhr.setRequestHeader('content-type', 'application/json');
xhr.send(data);
import axios from 'axios';
const options = {
method: 'POST',
url: '{{baseUrl}}/sendLocation',
headers: {'content-type': 'application/json'},
data: {
allow_sending_without_reply: false,
chat_id: '',
disable_notification: false,
heading: 0,
horizontal_accuracy: '',
latitude: '',
live_period: 0,
longitude: '',
proximity_alert_radius: 0,
reply_markup: '',
reply_to_message_id: 0
}
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const url = '{{baseUrl}}/sendLocation';
const options = {
method: 'POST',
headers: {'content-type': 'application/json'},
body: '{"allow_sending_without_reply":false,"chat_id":"","disable_notification":false,"heading":0,"horizontal_accuracy":"","latitude":"","live_period":0,"longitude":"","proximity_alert_radius":0,"reply_markup":"","reply_to_message_id":0}'
};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
const settings = {
async: true,
crossDomain: true,
url: '{{baseUrl}}/sendLocation',
method: 'POST',
headers: {
'content-type': 'application/json'
},
processData: false,
data: '{\n "allow_sending_without_reply": false,\n "chat_id": "",\n "disable_notification": false,\n "heading": 0,\n "horizontal_accuracy": "",\n "latitude": "",\n "live_period": 0,\n "longitude": "",\n "proximity_alert_radius": 0,\n "reply_markup": "",\n "reply_to_message_id": 0\n}'
};
$.ajax(settings).done(function (response) {
console.log(response);
});
val client = OkHttpClient()
val mediaType = MediaType.parse("application/json")
val body = RequestBody.create(mediaType, "{\n \"allow_sending_without_reply\": false,\n \"chat_id\": \"\",\n \"disable_notification\": false,\n \"heading\": 0,\n \"horizontal_accuracy\": \"\",\n \"latitude\": \"\",\n \"live_period\": 0,\n \"longitude\": \"\",\n \"proximity_alert_radius\": 0,\n \"reply_markup\": \"\",\n \"reply_to_message_id\": 0\n}")
val request = Request.Builder()
.url("{{baseUrl}}/sendLocation")
.post(body)
.addHeader("content-type", "application/json")
.build()
val response = client.newCall(request).execute()
const http = require('https');
const options = {
method: 'POST',
hostname: 'example.com',
port: null,
path: '/baseUrl/sendLocation',
headers: {
'content-type': 'application/json'
}
};
const req = http.request(options, function (res) {
const chunks = [];
res.on('data', function (chunk) {
chunks.push(chunk);
});
res.on('end', function () {
const body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.write(JSON.stringify({
allow_sending_without_reply: false,
chat_id: '',
disable_notification: false,
heading: 0,
horizontal_accuracy: '',
latitude: '',
live_period: 0,
longitude: '',
proximity_alert_radius: 0,
reply_markup: '',
reply_to_message_id: 0
}));
req.end();
const request = require('request');
const options = {
method: 'POST',
url: '{{baseUrl}}/sendLocation',
headers: {'content-type': 'application/json'},
body: {
allow_sending_without_reply: false,
chat_id: '',
disable_notification: false,
heading: 0,
horizontal_accuracy: '',
latitude: '',
live_period: 0,
longitude: '',
proximity_alert_radius: 0,
reply_markup: '',
reply_to_message_id: 0
},
json: true
};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
const unirest = require('unirest');
const req = unirest('POST', '{{baseUrl}}/sendLocation');
req.headers({
'content-type': 'application/json'
});
req.type('json');
req.send({
allow_sending_without_reply: false,
chat_id: '',
disable_notification: false,
heading: 0,
horizontal_accuracy: '',
latitude: '',
live_period: 0,
longitude: '',
proximity_alert_radius: 0,
reply_markup: '',
reply_to_message_id: 0
});
req.end(function (res) {
if (res.error) throw new Error(res.error);
console.log(res.body);
});
const axios = require('axios').default;
const options = {
method: 'POST',
url: '{{baseUrl}}/sendLocation',
headers: {'content-type': 'application/json'},
data: {
allow_sending_without_reply: false,
chat_id: '',
disable_notification: false,
heading: 0,
horizontal_accuracy: '',
latitude: '',
live_period: 0,
longitude: '',
proximity_alert_radius: 0,
reply_markup: '',
reply_to_message_id: 0
}
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const fetch = require('node-fetch');
const url = '{{baseUrl}}/sendLocation';
const options = {
method: 'POST',
headers: {'content-type': 'application/json'},
body: '{"allow_sending_without_reply":false,"chat_id":"","disable_notification":false,"heading":0,"horizontal_accuracy":"","latitude":"","live_period":0,"longitude":"","proximity_alert_radius":0,"reply_markup":"","reply_to_message_id":0}'
};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
#import
NSDictionary *headers = @{ @"content-type": @"application/json" };
NSDictionary *parameters = @{ @"allow_sending_without_reply": @NO,
@"chat_id": @"",
@"disable_notification": @NO,
@"heading": @0,
@"horizontal_accuracy": @"",
@"latitude": @"",
@"live_period": @0,
@"longitude": @"",
@"proximity_alert_radius": @0,
@"reply_markup": @"",
@"reply_to_message_id": @0 };
NSData *postData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"{{baseUrl}}/sendLocation"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
[request setHTTPMethod:@"POST"];
[request setAllHTTPHeaderFields:headers];
[request setHTTPBody:postData];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSLog(@"%@", httpResponse);
}
}];
[dataTask resume];
open Cohttp_lwt_unix
open Cohttp
open Lwt
let uri = Uri.of_string "{{baseUrl}}/sendLocation" in
let headers = Header.add (Header.init ()) "content-type" "application/json" in
let body = Cohttp_lwt_body.of_string "{\n \"allow_sending_without_reply\": false,\n \"chat_id\": \"\",\n \"disable_notification\": false,\n \"heading\": 0,\n \"horizontal_accuracy\": \"\",\n \"latitude\": \"\",\n \"live_period\": 0,\n \"longitude\": \"\",\n \"proximity_alert_radius\": 0,\n \"reply_markup\": \"\",\n \"reply_to_message_id\": 0\n}" in
Client.call ~headers ~body `POST uri
>>= fun (res, body_stream) ->
(* Do stuff with the result *)
"{{baseUrl}}/sendLocation",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'allow_sending_without_reply' => null,
'chat_id' => '',
'disable_notification' => null,
'heading' => 0,
'horizontal_accuracy' => '',
'latitude' => '',
'live_period' => 0,
'longitude' => '',
'proximity_alert_radius' => 0,
'reply_markup' => '',
'reply_to_message_id' => 0
]),
CURLOPT_HTTPHEADER => [
"content-type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
request('POST', '{{baseUrl}}/sendLocation', [
'body' => '{
"allow_sending_without_reply": false,
"chat_id": "",
"disable_notification": false,
"heading": 0,
"horizontal_accuracy": "",
"latitude": "",
"live_period": 0,
"longitude": "",
"proximity_alert_radius": 0,
"reply_markup": "",
"reply_to_message_id": 0
}',
'headers' => [
'content-type' => 'application/json',
],
]);
echo $response->getBody();
setUrl('{{baseUrl}}/sendLocation');
$request->setMethod(HTTP_METH_POST);
$request->setHeaders([
'content-type' => 'application/json'
]);
$request->setContentType('application/json');
$request->setBody(json_encode([
'allow_sending_without_reply' => null,
'chat_id' => '',
'disable_notification' => null,
'heading' => 0,
'horizontal_accuracy' => '',
'latitude' => '',
'live_period' => 0,
'longitude' => '',
'proximity_alert_radius' => 0,
'reply_markup' => '',
'reply_to_message_id' => 0
]));
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
append(json_encode([
'allow_sending_without_reply' => null,
'chat_id' => '',
'disable_notification' => null,
'heading' => 0,
'horizontal_accuracy' => '',
'latitude' => '',
'live_period' => 0,
'longitude' => '',
'proximity_alert_radius' => 0,
'reply_markup' => '',
'reply_to_message_id' => 0
]));
$request->setRequestUrl('{{baseUrl}}/sendLocation');
$request->setRequestMethod('POST');
$request->setBody($body);
$request->setHeaders([
'content-type' => 'application/json'
]);
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
$headers=@{}
$headers.Add("content-type", "application/json")
$response = Invoke-WebRequest -Uri '{{baseUrl}}/sendLocation' -Method POST -Headers $headers -ContentType 'application/json' -Body '{
"allow_sending_without_reply": false,
"chat_id": "",
"disable_notification": false,
"heading": 0,
"horizontal_accuracy": "",
"latitude": "",
"live_period": 0,
"longitude": "",
"proximity_alert_radius": 0,
"reply_markup": "",
"reply_to_message_id": 0
}'
$headers=@{}
$headers.Add("content-type", "application/json")
$response = Invoke-RestMethod -Uri '{{baseUrl}}/sendLocation' -Method POST -Headers $headers -ContentType 'application/json' -Body '{
"allow_sending_without_reply": false,
"chat_id": "",
"disable_notification": false,
"heading": 0,
"horizontal_accuracy": "",
"latitude": "",
"live_period": 0,
"longitude": "",
"proximity_alert_radius": 0,
"reply_markup": "",
"reply_to_message_id": 0
}'
import http.client
conn = http.client.HTTPSConnection("example.com")
payload = "{\n \"allow_sending_without_reply\": false,\n \"chat_id\": \"\",\n \"disable_notification\": false,\n \"heading\": 0,\n \"horizontal_accuracy\": \"\",\n \"latitude\": \"\",\n \"live_period\": 0,\n \"longitude\": \"\",\n \"proximity_alert_radius\": 0,\n \"reply_markup\": \"\",\n \"reply_to_message_id\": 0\n}"
headers = { 'content-type': "application/json" }
conn.request("POST", "/baseUrl/sendLocation", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
import requests
url = "{{baseUrl}}/sendLocation"
payload = {
"allow_sending_without_reply": False,
"chat_id": "",
"disable_notification": False,
"heading": 0,
"horizontal_accuracy": "",
"latitude": "",
"live_period": 0,
"longitude": "",
"proximity_alert_radius": 0,
"reply_markup": "",
"reply_to_message_id": 0
}
headers = {"content-type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
library(httr)
url <- "{{baseUrl}}/sendLocation"
payload <- "{\n \"allow_sending_without_reply\": false,\n \"chat_id\": \"\",\n \"disable_notification\": false,\n \"heading\": 0,\n \"horizontal_accuracy\": \"\",\n \"latitude\": \"\",\n \"live_period\": 0,\n \"longitude\": \"\",\n \"proximity_alert_radius\": 0,\n \"reply_markup\": \"\",\n \"reply_to_message_id\": 0\n}"
encode <- "json"
response <- VERB("POST", url, body = payload, content_type("application/json"), encode = encode)
content(response, "text")
require 'uri'
require 'net/http'
url = URI("{{baseUrl}}/sendLocation")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["content-type"] = 'application/json'
request.body = "{\n \"allow_sending_without_reply\": false,\n \"chat_id\": \"\",\n \"disable_notification\": false,\n \"heading\": 0,\n \"horizontal_accuracy\": \"\",\n \"latitude\": \"\",\n \"live_period\": 0,\n \"longitude\": \"\",\n \"proximity_alert_radius\": 0,\n \"reply_markup\": \"\",\n \"reply_to_message_id\": 0\n}"
response = http.request(request)
puts response.read_body
require 'faraday'
conn = Faraday.new(
url: 'https://example.com',
headers: {'Content-Type' => 'application/json'}
)
response = conn.post('/baseUrl/sendLocation') do |req|
req.body = "{\n \"allow_sending_without_reply\": false,\n \"chat_id\": \"\",\n \"disable_notification\": false,\n \"heading\": 0,\n \"horizontal_accuracy\": \"\",\n \"latitude\": \"\",\n \"live_period\": 0,\n \"longitude\": \"\",\n \"proximity_alert_radius\": 0,\n \"reply_markup\": \"\",\n \"reply_to_message_id\": 0\n}"
end
puts response.status
puts response.body
use serde_json::json;
use reqwest;
#[tokio::main]
pub async fn main() {
let url = "{{baseUrl}}/sendLocation";
let payload = json!({
"allow_sending_without_reply": false,
"chat_id": "",
"disable_notification": false,
"heading": 0,
"horizontal_accuracy": "",
"latitude": "",
"live_period": 0,
"longitude": "",
"proximity_alert_radius": 0,
"reply_markup": "",
"reply_to_message_id": 0
});
let mut headers = reqwest::header::HeaderMap::new();
headers.insert("content-type", "application/json".parse().unwrap());
let client = reqwest::Client::new();
let response = client.post(url)
.headers(headers)
.json(&payload)
.send()
.await;
let results = response.unwrap()
.json::()
.await
.unwrap();
dbg!(results);
}
curl --request POST \
--url {{baseUrl}}/sendLocation \
--header 'content-type: application/json' \
--data '{
"allow_sending_without_reply": false,
"chat_id": "",
"disable_notification": false,
"heading": 0,
"horizontal_accuracy": "",
"latitude": "",
"live_period": 0,
"longitude": "",
"proximity_alert_radius": 0,
"reply_markup": "",
"reply_to_message_id": 0
}'
echo '{
"allow_sending_without_reply": false,
"chat_id": "",
"disable_notification": false,
"heading": 0,
"horizontal_accuracy": "",
"latitude": "",
"live_period": 0,
"longitude": "",
"proximity_alert_radius": 0,
"reply_markup": "",
"reply_to_message_id": 0
}' | \
http POST {{baseUrl}}/sendLocation \
content-type:application/json
wget --quiet \
--method POST \
--header 'content-type: application/json' \
--body-data '{\n "allow_sending_without_reply": false,\n "chat_id": "",\n "disable_notification": false,\n "heading": 0,\n "horizontal_accuracy": "",\n "latitude": "",\n "live_period": 0,\n "longitude": "",\n "proximity_alert_radius": 0,\n "reply_markup": "",\n "reply_to_message_id": 0\n}' \
--output-document \
- {{baseUrl}}/sendLocation
import Foundation
let headers = ["content-type": "application/json"]
let parameters = [
"allow_sending_without_reply": false,
"chat_id": "",
"disable_notification": false,
"heading": 0,
"horizontal_accuracy": "",
"latitude": "",
"live_period": 0,
"longitude": "",
"proximity_alert_radius": 0,
"reply_markup": "",
"reply_to_message_id": 0
] as [String : Any]
let postData = JSONSerialization.data(withJSONObject: parameters, options: [])
let request = NSMutableURLRequest(url: NSURL(string: "{{baseUrl}}/sendLocation")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error as Any)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
POST
Use this method to send static .WEBP or [animated](https---telegram.org-blog-animated-stickers) .TGS stickers. On success, the sent [Message](https---core.telegram.org-bots-api-#message) is returned.
{{baseUrl}}/sendSticker
BODY multipartForm
Examples
REQUEST
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(hnd, CURLOPT_URL, "{{baseUrl}}/sendSticker");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "content-type: multipart/form-data; boundary=---011000010111000001101001");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"allow_sending_without_reply\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"chat_id\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"disable_notification\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"reply_markup\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"reply_to_message_id\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"sticker\"\r\n\r\n\r\n-----011000010111000001101001--\r\n");
CURLcode ret = curl_easy_perform(hnd);
(require '[clj-http.client :as client])
(client/post "{{baseUrl}}/sendSticker" {:multipart [{:name "allow_sending_without_reply"
:content ""} {:name "chat_id"
:content ""} {:name "disable_notification"
:content ""} {:name "reply_markup"
:content ""} {:name "reply_to_message_id"
:content ""} {:name "sticker"
:content ""}]})
require "http/client"
url = "{{baseUrl}}/sendSticker"
headers = HTTP::Headers{
"content-type" => "multipart/form-data; boundary=---011000010111000001101001"
}
reqBody = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"allow_sending_without_reply\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"chat_id\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"disable_notification\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"reply_markup\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"reply_to_message_id\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"sticker\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"
response = HTTP::Client.post url, headers: headers, body: reqBody
puts response.body
using System.Net.Http.Headers;
var client = new HttpClient();
var request = new HttpRequestMessage
{
Method = HttpMethod.Post,
RequestUri = new Uri("{{baseUrl}}/sendSticker"),
Content = new MultipartFormDataContent
{
new StringContent("")
{
Headers =
{
ContentDisposition = new ContentDispositionHeaderValue("form-data")
{
Name = "allow_sending_without_reply",
}
}
},
new StringContent("")
{
Headers =
{
ContentDisposition = new ContentDispositionHeaderValue("form-data")
{
Name = "chat_id",
}
}
},
new StringContent("")
{
Headers =
{
ContentDisposition = new ContentDispositionHeaderValue("form-data")
{
Name = "disable_notification",
}
}
},
new StringContent("")
{
Headers =
{
ContentDisposition = new ContentDispositionHeaderValue("form-data")
{
Name = "reply_markup",
}
}
},
new StringContent("")
{
Headers =
{
ContentDisposition = new ContentDispositionHeaderValue("form-data")
{
Name = "reply_to_message_id",
}
}
},
new StringContent("")
{
Headers =
{
ContentDisposition = new ContentDispositionHeaderValue("form-data")
{
Name = "sticker",
}
}
},
},
};
using (var response = await client.SendAsync(request))
{
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
}
var client = new RestClient("{{baseUrl}}/sendSticker");
var request = new RestRequest("", Method.Post);
request.AddHeader("content-type", "multipart/form-data; boundary=---011000010111000001101001");
request.AddParameter("multipart/form-data; boundary=---011000010111000001101001", "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"allow_sending_without_reply\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"chat_id\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"disable_notification\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"reply_markup\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"reply_to_message_id\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"sticker\"\r\n\r\n\r\n-----011000010111000001101001--\r\n", ParameterType.RequestBody);
var response = client.Execute(request);
package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "{{baseUrl}}/sendSticker"
payload := strings.NewReader("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"allow_sending_without_reply\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"chat_id\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"disable_notification\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"reply_markup\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"reply_to_message_id\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"sticker\"\r\n\r\n\r\n-----011000010111000001101001--\r\n")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("content-type", "multipart/form-data; boundary=---011000010111000001101001")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
POST /baseUrl/sendSticker HTTP/1.1
Content-Type: multipart/form-data; boundary=---011000010111000001101001
Host: example.com
Content-Length: 581
-----011000010111000001101001
Content-Disposition: form-data; name="allow_sending_without_reply"
-----011000010111000001101001
Content-Disposition: form-data; name="chat_id"
-----011000010111000001101001
Content-Disposition: form-data; name="disable_notification"
-----011000010111000001101001
Content-Disposition: form-data; name="reply_markup"
-----011000010111000001101001
Content-Disposition: form-data; name="reply_to_message_id"
-----011000010111000001101001
Content-Disposition: form-data; name="sticker"
-----011000010111000001101001--
AsyncHttpClient client = new DefaultAsyncHttpClient();
client.prepare("POST", "{{baseUrl}}/sendSticker")
.setHeader("content-type", "multipart/form-data; boundary=---011000010111000001101001")
.setBody("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"allow_sending_without_reply\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"chat_id\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"disable_notification\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"reply_markup\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"reply_to_message_id\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"sticker\"\r\n\r\n\r\n-----011000010111000001101001--\r\n")
.execute()
.toCompletableFuture()
.thenAccept(System.out::println)
.join();
client.close();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("{{baseUrl}}/sendSticker"))
.header("content-type", "multipart/form-data; boundary=---011000010111000001101001")
.method("POST", HttpRequest.BodyPublishers.ofString("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"allow_sending_without_reply\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"chat_id\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"disable_notification\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"reply_markup\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"reply_to_message_id\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"sticker\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"))
.build();
HttpResponse response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("multipart/form-data; boundary=---011000010111000001101001");
RequestBody body = RequestBody.create(mediaType, "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"allow_sending_without_reply\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"chat_id\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"disable_notification\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"reply_markup\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"reply_to_message_id\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"sticker\"\r\n\r\n\r\n-----011000010111000001101001--\r\n");
Request request = new Request.Builder()
.url("{{baseUrl}}/sendSticker")
.post(body)
.addHeader("content-type", "multipart/form-data; boundary=---011000010111000001101001")
.build();
Response response = client.newCall(request).execute();
HttpResponse response = Unirest.post("{{baseUrl}}/sendSticker")
.header("content-type", "multipart/form-data; boundary=---011000010111000001101001")
.body("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"allow_sending_without_reply\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"chat_id\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"disable_notification\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"reply_markup\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"reply_to_message_id\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"sticker\"\r\n\r\n\r\n-----011000010111000001101001--\r\n")
.asString();
const data = new FormData();
data.append('allow_sending_without_reply', '');
data.append('chat_id', '');
data.append('disable_notification', '');
data.append('reply_markup', '');
data.append('reply_to_message_id', '');
data.append('sticker', '');
const xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener('readystatechange', function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open('POST', '{{baseUrl}}/sendSticker');
xhr.send(data);
import axios from 'axios';
const form = new FormData();
form.append('allow_sending_without_reply', '');
form.append('chat_id', '');
form.append('disable_notification', '');
form.append('reply_markup', '');
form.append('reply_to_message_id', '');
form.append('sticker', '');
const options = {
method: 'POST',
url: '{{baseUrl}}/sendSticker',
headers: {'content-type': 'multipart/form-data; boundary=---011000010111000001101001'},
data: '[form]'
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const url = '{{baseUrl}}/sendSticker';
const form = new FormData();
form.append('allow_sending_without_reply', '');
form.append('chat_id', '');
form.append('disable_notification', '');
form.append('reply_markup', '');
form.append('reply_to_message_id', '');
form.append('sticker', '');
const options = {method: 'POST'};
options.body = form;
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
const form = new FormData();
form.append('allow_sending_without_reply', '');
form.append('chat_id', '');
form.append('disable_notification', '');
form.append('reply_markup', '');
form.append('reply_to_message_id', '');
form.append('sticker', '');
const settings = {
async: true,
crossDomain: true,
url: '{{baseUrl}}/sendSticker',
method: 'POST',
headers: {},
processData: false,
contentType: false,
mimeType: 'multipart/form-data',
data: form
};
$.ajax(settings).done(function (response) {
console.log(response);
});
val client = OkHttpClient()
val mediaType = MediaType.parse("multipart/form-data; boundary=---011000010111000001101001")
val body = RequestBody.create(mediaType, "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"allow_sending_without_reply\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"chat_id\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"disable_notification\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"reply_markup\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"reply_to_message_id\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"sticker\"\r\n\r\n\r\n-----011000010111000001101001--\r\n")
val request = Request.Builder()
.url("{{baseUrl}}/sendSticker")
.post(body)
.addHeader("content-type", "multipart/form-data; boundary=---011000010111000001101001")
.build()
val response = client.newCall(request).execute()
const http = require('https');
const options = {
method: 'POST',
hostname: 'example.com',
port: null,
path: '/baseUrl/sendSticker',
headers: {
'content-type': 'multipart/form-data; boundary=---011000010111000001101001'
}
};
const req = http.request(options, function (res) {
const chunks = [];
res.on('data', function (chunk) {
chunks.push(chunk);
});
res.on('end', function () {
const body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.write('-----011000010111000001101001\r\nContent-Disposition: form-data; name="allow_sending_without_reply"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name="chat_id"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name="disable_notification"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name="reply_markup"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name="reply_to_message_id"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name="sticker"\r\n\r\n\r\n-----011000010111000001101001--\r\n');
req.end();
const request = require('request');
const options = {
method: 'POST',
url: '{{baseUrl}}/sendSticker',
headers: {'content-type': 'multipart/form-data; boundary=---011000010111000001101001'},
formData: {
allow_sending_without_reply: '',
chat_id: '',
disable_notification: '',
reply_markup: '',
reply_to_message_id: '',
sticker: ''
}
};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
const unirest = require('unirest');
const req = unirest('POST', '{{baseUrl}}/sendSticker');
req.headers({
'content-type': 'multipart/form-data; boundary=---011000010111000001101001'
});
req.multipart([]);
req.end(function (res) {
if (res.error) throw new Error(res.error);
console.log(res.body);
});
const axios = require('axios').default;
const options = {
method: 'POST',
url: '{{baseUrl}}/sendSticker',
headers: {'content-type': 'multipart/form-data; boundary=---011000010111000001101001'},
data: '-----011000010111000001101001\r\nContent-Disposition: form-data; name="allow_sending_without_reply"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name="chat_id"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name="disable_notification"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name="reply_markup"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name="reply_to_message_id"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name="sticker"\r\n\r\n\r\n-----011000010111000001101001--\r\n'
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const FormData = require('form-data');
const fetch = require('node-fetch');
const formData = new FormData();
formData.append('allow_sending_without_reply', '');
formData.append('chat_id', '');
formData.append('disable_notification', '');
formData.append('reply_markup', '');
formData.append('reply_to_message_id', '');
formData.append('sticker', '');
const url = '{{baseUrl}}/sendSticker';
const options = {method: 'POST'};
options.body = formData;
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
#import
NSDictionary *headers = @{ @"content-type": @"multipart/form-data; boundary=---011000010111000001101001" };
NSArray *parameters = @[ @{ @"name": @"allow_sending_without_reply", @"value": @"" },
@{ @"name": @"chat_id", @"value": @"" },
@{ @"name": @"disable_notification", @"value": @"" },
@{ @"name": @"reply_markup", @"value": @"" },
@{ @"name": @"reply_to_message_id", @"value": @"" },
@{ @"name": @"sticker", @"value": @"" } ];
NSString *boundary = @"---011000010111000001101001";
NSError *error;
NSMutableString *body = [NSMutableString string];
for (NSDictionary *param in parameters) {
[body appendFormat:@"--%@\r\n", boundary];
if (param[@"fileName"]) {
[body appendFormat:@"Content-Disposition:form-data; name=\"%@\"; filename=\"%@\"\r\n", param[@"name"], param[@"fileName"]];
[body appendFormat:@"Content-Type: %@\r\n\r\n", param[@"contentType"]];
[body appendFormat:@"%@", [NSString stringWithContentsOfFile:param[@"fileName"] encoding:NSUTF8StringEncoding error:&error]];
if (error) {
NSLog(@"%@", error);
}
} else {
[body appendFormat:@"Content-Disposition:form-data; name=\"%@\"\r\n\r\n", param[@"name"]];
[body appendFormat:@"%@", param[@"value"]];
}
}
[body appendFormat:@"\r\n--%@--\r\n", boundary];
NSData *postData = [body dataUsingEncoding:NSUTF8StringEncoding];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"{{baseUrl}}/sendSticker"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
[request setHTTPMethod:@"POST"];
[request setAllHTTPHeaderFields:headers];
[request setHTTPBody:postData];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSLog(@"%@", httpResponse);
}
}];
[dataTask resume];
open Cohttp_lwt_unix
open Cohttp
open Lwt
let uri = Uri.of_string "{{baseUrl}}/sendSticker" in
let headers = Header.add (Header.init ()) "content-type" "multipart/form-data; boundary=---011000010111000001101001" in
let body = Cohttp_lwt_body.of_string "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"allow_sending_without_reply\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"chat_id\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"disable_notification\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"reply_markup\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"reply_to_message_id\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"sticker\"\r\n\r\n\r\n-----011000010111000001101001--\r\n" in
Client.call ~headers ~body `POST uri
>>= fun (res, body_stream) ->
(* Do stuff with the result *)
"{{baseUrl}}/sendSticker",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"allow_sending_without_reply\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"chat_id\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"disable_notification\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"reply_markup\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"reply_to_message_id\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"sticker\"\r\n\r\n\r\n-----011000010111000001101001--\r\n",
CURLOPT_HTTPHEADER => [
"content-type: multipart/form-data; boundary=---011000010111000001101001"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
request('POST', '{{baseUrl}}/sendSticker', [
'headers' => [
'content-type' => 'multipart/form-data; boundary=---011000010111000001101001',
],
]);
echo $response->getBody();
setUrl('{{baseUrl}}/sendSticker');
$request->setMethod(HTTP_METH_POST);
$request->setHeaders([
'content-type' => 'multipart/form-data; boundary=---011000010111000001101001'
]);
$request->setBody('-----011000010111000001101001
Content-Disposition: form-data; name="allow_sending_without_reply"
-----011000010111000001101001
Content-Disposition: form-data; name="chat_id"
-----011000010111000001101001
Content-Disposition: form-data; name="disable_notification"
-----011000010111000001101001
Content-Disposition: form-data; name="reply_markup"
-----011000010111000001101001
Content-Disposition: form-data; name="reply_to_message_id"
-----011000010111000001101001
Content-Disposition: form-data; name="sticker"
-----011000010111000001101001--
');
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
addForm(null, null);
$request->setRequestUrl('{{baseUrl}}/sendSticker');
$request->setRequestMethod('POST');
$request->setBody($body);
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
$headers=@{}
$headers.Add("content-type", "multipart/form-data; boundary=---011000010111000001101001")
$response = Invoke-WebRequest -Uri '{{baseUrl}}/sendSticker' -Method POST -Headers $headers -ContentType 'multipart/form-data; boundary=---011000010111000001101001' -Body '-----011000010111000001101001
Content-Disposition: form-data; name="allow_sending_without_reply"
-----011000010111000001101001
Content-Disposition: form-data; name="chat_id"
-----011000010111000001101001
Content-Disposition: form-data; name="disable_notification"
-----011000010111000001101001
Content-Disposition: form-data; name="reply_markup"
-----011000010111000001101001
Content-Disposition: form-data; name="reply_to_message_id"
-----011000010111000001101001
Content-Disposition: form-data; name="sticker"
-----011000010111000001101001--
'
$headers=@{}
$headers.Add("content-type", "multipart/form-data; boundary=---011000010111000001101001")
$response = Invoke-RestMethod -Uri '{{baseUrl}}/sendSticker' -Method POST -Headers $headers -ContentType 'multipart/form-data; boundary=---011000010111000001101001' -Body '-----011000010111000001101001
Content-Disposition: form-data; name="allow_sending_without_reply"
-----011000010111000001101001
Content-Disposition: form-data; name="chat_id"
-----011000010111000001101001
Content-Disposition: form-data; name="disable_notification"
-----011000010111000001101001
Content-Disposition: form-data; name="reply_markup"
-----011000010111000001101001
Content-Disposition: form-data; name="reply_to_message_id"
-----011000010111000001101001
Content-Disposition: form-data; name="sticker"
-----011000010111000001101001--
'
import http.client
conn = http.client.HTTPSConnection("example.com")
payload = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"allow_sending_without_reply\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"chat_id\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"disable_notification\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"reply_markup\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"reply_to_message_id\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"sticker\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"
headers = { 'content-type': "multipart/form-data; boundary=---011000010111000001101001" }
conn.request("POST", "/baseUrl/sendSticker", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
import requests
url = "{{baseUrl}}/sendSticker"
payload = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"allow_sending_without_reply\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"chat_id\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"disable_notification\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"reply_markup\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"reply_to_message_id\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"sticker\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"
headers = {"content-type": "multipart/form-data; boundary=---011000010111000001101001"}
response = requests.post(url, data=payload, headers=headers)
print(response.json())
library(httr)
url <- "{{baseUrl}}/sendSticker"
payload <- "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"allow_sending_without_reply\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"chat_id\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"disable_notification\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"reply_markup\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"reply_to_message_id\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"sticker\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"
encode <- "multipart"
response <- VERB("POST", url, body = payload, content_type("multipart/form-data"), encode = encode)
content(response, "text")
require 'uri'
require 'net/http'
url = URI("{{baseUrl}}/sendSticker")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["content-type"] = 'multipart/form-data; boundary=---011000010111000001101001'
request.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"allow_sending_without_reply\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"chat_id\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"disable_notification\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"reply_markup\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"reply_to_message_id\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"sticker\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"
response = http.request(request)
puts response.read_body
require 'faraday'
conn = Faraday.new(
url: 'https://example.com',
headers: {'Content-Type' => 'multipart/form-data; boundary=---011000010111000001101001'}
)
response = conn.post('/baseUrl/sendSticker') do |req|
req.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"allow_sending_without_reply\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"chat_id\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"disable_notification\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"reply_markup\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"reply_to_message_id\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"sticker\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"
end
puts response.status
puts response.body
use reqwest;
#[tokio::main]
pub async fn main() {
let url = "{{baseUrl}}/sendSticker";
let form = reqwest::multipart::Form::new()
.text("allow_sending_without_reply", "")
.text("chat_id", "")
.text("disable_notification", "")
.text("reply_markup", "")
.text("reply_to_message_id", "")
.text("sticker", "");
let mut headers = reqwest::header::HeaderMap::new();
let client = reqwest::Client::new();
let response = client.post(url)
.multipart(form)
.headers(headers)
.send()
.await;
let results = response.unwrap()
.json::()
.await
.unwrap();
dbg!(results);
}
curl --request POST \
--url {{baseUrl}}/sendSticker \
--header 'content-type: multipart/form-data' \
--form allow_sending_without_reply= \
--form chat_id= \
--form disable_notification= \
--form reply_markup= \
--form reply_to_message_id= \
--form sticker=
echo '-----011000010111000001101001
Content-Disposition: form-data; name="allow_sending_without_reply"
-----011000010111000001101001
Content-Disposition: form-data; name="chat_id"
-----011000010111000001101001
Content-Disposition: form-data; name="disable_notification"
-----011000010111000001101001
Content-Disposition: form-data; name="reply_markup"
-----011000010111000001101001
Content-Disposition: form-data; name="reply_to_message_id"
-----011000010111000001101001
Content-Disposition: form-data; name="sticker"
-----011000010111000001101001--
' | \
http POST {{baseUrl}}/sendSticker \
content-type:'multipart/form-data; boundary=---011000010111000001101001'
wget --quiet \
--method POST \
--header 'content-type: multipart/form-data; boundary=---011000010111000001101001' \
--body-data '-----011000010111000001101001\r\nContent-Disposition: form-data; name="allow_sending_without_reply"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name="chat_id"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name="disable_notification"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name="reply_markup"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name="reply_to_message_id"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name="sticker"\r\n\r\n\r\n-----011000010111000001101001--\r\n' \
--output-document \
- {{baseUrl}}/sendSticker
import Foundation
let headers = ["content-type": "multipart/form-data; boundary=---011000010111000001101001"]
let parameters = [
[
"name": "allow_sending_without_reply",
"value": ""
],
[
"name": "chat_id",
"value": ""
],
[
"name": "disable_notification",
"value": ""
],
[
"name": "reply_markup",
"value": ""
],
[
"name": "reply_to_message_id",
"value": ""
],
[
"name": "sticker",
"value": ""
]
]
let boundary = "---011000010111000001101001"
var body = ""
var error: NSError? = nil
for param in parameters {
let paramName = param["name"]!
body += "--\(boundary)\r\n"
body += "Content-Disposition:form-data; name=\"\(paramName)\""
if let filename = param["fileName"] {
let contentType = param["content-type"]!
let fileContent = String(contentsOfFile: filename, encoding: String.Encoding.utf8)
if (error != nil) {
print(error as Any)
}
body += "; filename=\"\(filename)\"\r\n"
body += "Content-Type: \(contentType)\r\n\r\n"
body += fileContent
} else if let paramValue = param["value"] {
body += "\r\n\r\n\(paramValue)"
}
}
let request = NSMutableURLRequest(url: NSURL(string: "{{baseUrl}}/sendSticker")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error as Any)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
POST
Use this method to send text messages. On success, the sent [Message](https---core.telegram.org-bots-api-#message) is returned.
{{baseUrl}}/sendMessage
BODY json
{
"allow_sending_without_reply": false,
"chat_id": "",
"disable_notification": false,
"disable_web_page_preview": false,
"entities": [
{
"language": "",
"length": 0,
"offset": 0,
"type": "",
"url": "",
"user": {
"can_join_groups": false,
"can_read_all_group_messages": false,
"first_name": "",
"id": 0,
"is_bot": false,
"language_code": "",
"last_name": "",
"supports_inline_queries": false,
"username": ""
}
}
],
"parse_mode": "",
"reply_markup": "",
"reply_to_message_id": 0,
"text": ""
}
Examples
REQUEST
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(hnd, CURLOPT_URL, "{{baseUrl}}/sendMessage");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "content-type: application/json");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "{\n \"allow_sending_without_reply\": false,\n \"chat_id\": \"\",\n \"disable_notification\": false,\n \"disable_web_page_preview\": false,\n \"entities\": [\n {\n \"language\": \"\",\n \"length\": 0,\n \"offset\": 0,\n \"type\": \"\",\n \"url\": \"\",\n \"user\": {\n \"can_join_groups\": false,\n \"can_read_all_group_messages\": false,\n \"first_name\": \"\",\n \"id\": 0,\n \"is_bot\": false,\n \"language_code\": \"\",\n \"last_name\": \"\",\n \"supports_inline_queries\": false,\n \"username\": \"\"\n }\n }\n ],\n \"parse_mode\": \"\",\n \"reply_markup\": \"\",\n \"reply_to_message_id\": 0,\n \"text\": \"\"\n}");
CURLcode ret = curl_easy_perform(hnd);
(require '[clj-http.client :as client])
(client/post "{{baseUrl}}/sendMessage" {:content-type :json
:form-params {:allow_sending_without_reply false
:chat_id ""
:disable_notification false
:disable_web_page_preview false
:entities [{:language ""
:length 0
:offset 0
:type ""
:url ""
:user {:can_join_groups false
:can_read_all_group_messages false
:first_name ""
:id 0
:is_bot false
:language_code ""
:last_name ""
:supports_inline_queries false
:username ""}}]
:parse_mode ""
:reply_markup ""
:reply_to_message_id 0
:text ""}})
require "http/client"
url = "{{baseUrl}}/sendMessage"
headers = HTTP::Headers{
"content-type" => "application/json"
}
reqBody = "{\n \"allow_sending_without_reply\": false,\n \"chat_id\": \"\",\n \"disable_notification\": false,\n \"disable_web_page_preview\": false,\n \"entities\": [\n {\n \"language\": \"\",\n \"length\": 0,\n \"offset\": 0,\n \"type\": \"\",\n \"url\": \"\",\n \"user\": {\n \"can_join_groups\": false,\n \"can_read_all_group_messages\": false,\n \"first_name\": \"\",\n \"id\": 0,\n \"is_bot\": false,\n \"language_code\": \"\",\n \"last_name\": \"\",\n \"supports_inline_queries\": false,\n \"username\": \"\"\n }\n }\n ],\n \"parse_mode\": \"\",\n \"reply_markup\": \"\",\n \"reply_to_message_id\": 0,\n \"text\": \"\"\n}"
response = HTTP::Client.post url, headers: headers, body: reqBody
puts response.body
using System.Net.Http.Headers;
var client = new HttpClient();
var request = new HttpRequestMessage
{
Method = HttpMethod.Post,
RequestUri = new Uri("{{baseUrl}}/sendMessage"),
Content = new StringContent("{\n \"allow_sending_without_reply\": false,\n \"chat_id\": \"\",\n \"disable_notification\": false,\n \"disable_web_page_preview\": false,\n \"entities\": [\n {\n \"language\": \"\",\n \"length\": 0,\n \"offset\": 0,\n \"type\": \"\",\n \"url\": \"\",\n \"user\": {\n \"can_join_groups\": false,\n \"can_read_all_group_messages\": false,\n \"first_name\": \"\",\n \"id\": 0,\n \"is_bot\": false,\n \"language_code\": \"\",\n \"last_name\": \"\",\n \"supports_inline_queries\": false,\n \"username\": \"\"\n }\n }\n ],\n \"parse_mode\": \"\",\n \"reply_markup\": \"\",\n \"reply_to_message_id\": 0,\n \"text\": \"\"\n}")
{
Headers =
{
ContentType = new MediaTypeHeaderValue("application/json")
}
}
};
using (var response = await client.SendAsync(request))
{
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
}
var client = new RestClient("{{baseUrl}}/sendMessage");
var request = new RestRequest("", Method.Post);
request.AddHeader("content-type", "application/json");
request.AddParameter("application/json", "{\n \"allow_sending_without_reply\": false,\n \"chat_id\": \"\",\n \"disable_notification\": false,\n \"disable_web_page_preview\": false,\n \"entities\": [\n {\n \"language\": \"\",\n \"length\": 0,\n \"offset\": 0,\n \"type\": \"\",\n \"url\": \"\",\n \"user\": {\n \"can_join_groups\": false,\n \"can_read_all_group_messages\": false,\n \"first_name\": \"\",\n \"id\": 0,\n \"is_bot\": false,\n \"language_code\": \"\",\n \"last_name\": \"\",\n \"supports_inline_queries\": false,\n \"username\": \"\"\n }\n }\n ],\n \"parse_mode\": \"\",\n \"reply_markup\": \"\",\n \"reply_to_message_id\": 0,\n \"text\": \"\"\n}", ParameterType.RequestBody);
var response = client.Execute(request);
package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "{{baseUrl}}/sendMessage"
payload := strings.NewReader("{\n \"allow_sending_without_reply\": false,\n \"chat_id\": \"\",\n \"disable_notification\": false,\n \"disable_web_page_preview\": false,\n \"entities\": [\n {\n \"language\": \"\",\n \"length\": 0,\n \"offset\": 0,\n \"type\": \"\",\n \"url\": \"\",\n \"user\": {\n \"can_join_groups\": false,\n \"can_read_all_group_messages\": false,\n \"first_name\": \"\",\n \"id\": 0,\n \"is_bot\": false,\n \"language_code\": \"\",\n \"last_name\": \"\",\n \"supports_inline_queries\": false,\n \"username\": \"\"\n }\n }\n ],\n \"parse_mode\": \"\",\n \"reply_markup\": \"\",\n \"reply_to_message_id\": 0,\n \"text\": \"\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("content-type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
POST /baseUrl/sendMessage HTTP/1.1
Content-Type: application/json
Host: example.com
Content-Length: 632
{
"allow_sending_without_reply": false,
"chat_id": "",
"disable_notification": false,
"disable_web_page_preview": false,
"entities": [
{
"language": "",
"length": 0,
"offset": 0,
"type": "",
"url": "",
"user": {
"can_join_groups": false,
"can_read_all_group_messages": false,
"first_name": "",
"id": 0,
"is_bot": false,
"language_code": "",
"last_name": "",
"supports_inline_queries": false,
"username": ""
}
}
],
"parse_mode": "",
"reply_markup": "",
"reply_to_message_id": 0,
"text": ""
}
AsyncHttpClient client = new DefaultAsyncHttpClient();
client.prepare("POST", "{{baseUrl}}/sendMessage")
.setHeader("content-type", "application/json")
.setBody("{\n \"allow_sending_without_reply\": false,\n \"chat_id\": \"\",\n \"disable_notification\": false,\n \"disable_web_page_preview\": false,\n \"entities\": [\n {\n \"language\": \"\",\n \"length\": 0,\n \"offset\": 0,\n \"type\": \"\",\n \"url\": \"\",\n \"user\": {\n \"can_join_groups\": false,\n \"can_read_all_group_messages\": false,\n \"first_name\": \"\",\n \"id\": 0,\n \"is_bot\": false,\n \"language_code\": \"\",\n \"last_name\": \"\",\n \"supports_inline_queries\": false,\n \"username\": \"\"\n }\n }\n ],\n \"parse_mode\": \"\",\n \"reply_markup\": \"\",\n \"reply_to_message_id\": 0,\n \"text\": \"\"\n}")
.execute()
.toCompletableFuture()
.thenAccept(System.out::println)
.join();
client.close();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("{{baseUrl}}/sendMessage"))
.header("content-type", "application/json")
.method("POST", HttpRequest.BodyPublishers.ofString("{\n \"allow_sending_without_reply\": false,\n \"chat_id\": \"\",\n \"disable_notification\": false,\n \"disable_web_page_preview\": false,\n \"entities\": [\n {\n \"language\": \"\",\n \"length\": 0,\n \"offset\": 0,\n \"type\": \"\",\n \"url\": \"\",\n \"user\": {\n \"can_join_groups\": false,\n \"can_read_all_group_messages\": false,\n \"first_name\": \"\",\n \"id\": 0,\n \"is_bot\": false,\n \"language_code\": \"\",\n \"last_name\": \"\",\n \"supports_inline_queries\": false,\n \"username\": \"\"\n }\n }\n ],\n \"parse_mode\": \"\",\n \"reply_markup\": \"\",\n \"reply_to_message_id\": 0,\n \"text\": \"\"\n}"))
.build();
HttpResponse response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n \"allow_sending_without_reply\": false,\n \"chat_id\": \"\",\n \"disable_notification\": false,\n \"disable_web_page_preview\": false,\n \"entities\": [\n {\n \"language\": \"\",\n \"length\": 0,\n \"offset\": 0,\n \"type\": \"\",\n \"url\": \"\",\n \"user\": {\n \"can_join_groups\": false,\n \"can_read_all_group_messages\": false,\n \"first_name\": \"\",\n \"id\": 0,\n \"is_bot\": false,\n \"language_code\": \"\",\n \"last_name\": \"\",\n \"supports_inline_queries\": false,\n \"username\": \"\"\n }\n }\n ],\n \"parse_mode\": \"\",\n \"reply_markup\": \"\",\n \"reply_to_message_id\": 0,\n \"text\": \"\"\n}");
Request request = new Request.Builder()
.url("{{baseUrl}}/sendMessage")
.post(body)
.addHeader("content-type", "application/json")
.build();
Response response = client.newCall(request).execute();
HttpResponse response = Unirest.post("{{baseUrl}}/sendMessage")
.header("content-type", "application/json")
.body("{\n \"allow_sending_without_reply\": false,\n \"chat_id\": \"\",\n \"disable_notification\": false,\n \"disable_web_page_preview\": false,\n \"entities\": [\n {\n \"language\": \"\",\n \"length\": 0,\n \"offset\": 0,\n \"type\": \"\",\n \"url\": \"\",\n \"user\": {\n \"can_join_groups\": false,\n \"can_read_all_group_messages\": false,\n \"first_name\": \"\",\n \"id\": 0,\n \"is_bot\": false,\n \"language_code\": \"\",\n \"last_name\": \"\",\n \"supports_inline_queries\": false,\n \"username\": \"\"\n }\n }\n ],\n \"parse_mode\": \"\",\n \"reply_markup\": \"\",\n \"reply_to_message_id\": 0,\n \"text\": \"\"\n}")
.asString();
const data = JSON.stringify({
allow_sending_without_reply: false,
chat_id: '',
disable_notification: false,
disable_web_page_preview: false,
entities: [
{
language: '',
length: 0,
offset: 0,
type: '',
url: '',
user: {
can_join_groups: false,
can_read_all_group_messages: false,
first_name: '',
id: 0,
is_bot: false,
language_code: '',
last_name: '',
supports_inline_queries: false,
username: ''
}
}
],
parse_mode: '',
reply_markup: '',
reply_to_message_id: 0,
text: ''
});
const xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener('readystatechange', function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open('POST', '{{baseUrl}}/sendMessage');
xhr.setRequestHeader('content-type', 'application/json');
xhr.send(data);
import axios from 'axios';
const options = {
method: 'POST',
url: '{{baseUrl}}/sendMessage',
headers: {'content-type': 'application/json'},
data: {
allow_sending_without_reply: false,
chat_id: '',
disable_notification: false,
disable_web_page_preview: false,
entities: [
{
language: '',
length: 0,
offset: 0,
type: '',
url: '',
user: {
can_join_groups: false,
can_read_all_group_messages: false,
first_name: '',
id: 0,
is_bot: false,
language_code: '',
last_name: '',
supports_inline_queries: false,
username: ''
}
}
],
parse_mode: '',
reply_markup: '',
reply_to_message_id: 0,
text: ''
}
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const url = '{{baseUrl}}/sendMessage';
const options = {
method: 'POST',
headers: {'content-type': 'application/json'},
body: '{"allow_sending_without_reply":false,"chat_id":"","disable_notification":false,"disable_web_page_preview":false,"entities":[{"language":"","length":0,"offset":0,"type":"","url":"","user":{"can_join_groups":false,"can_read_all_group_messages":false,"first_name":"","id":0,"is_bot":false,"language_code":"","last_name":"","supports_inline_queries":false,"username":""}}],"parse_mode":"","reply_markup":"","reply_to_message_id":0,"text":""}'
};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
const settings = {
async: true,
crossDomain: true,
url: '{{baseUrl}}/sendMessage',
method: 'POST',
headers: {
'content-type': 'application/json'
},
processData: false,
data: '{\n "allow_sending_without_reply": false,\n "chat_id": "",\n "disable_notification": false,\n "disable_web_page_preview": false,\n "entities": [\n {\n "language": "",\n "length": 0,\n "offset": 0,\n "type": "",\n "url": "",\n "user": {\n "can_join_groups": false,\n "can_read_all_group_messages": false,\n "first_name": "",\n "id": 0,\n "is_bot": false,\n "language_code": "",\n "last_name": "",\n "supports_inline_queries": false,\n "username": ""\n }\n }\n ],\n "parse_mode": "",\n "reply_markup": "",\n "reply_to_message_id": 0,\n "text": ""\n}'
};
$.ajax(settings).done(function (response) {
console.log(response);
});
val client = OkHttpClient()
val mediaType = MediaType.parse("application/json")
val body = RequestBody.create(mediaType, "{\n \"allow_sending_without_reply\": false,\n \"chat_id\": \"\",\n \"disable_notification\": false,\n \"disable_web_page_preview\": false,\n \"entities\": [\n {\n \"language\": \"\",\n \"length\": 0,\n \"offset\": 0,\n \"type\": \"\",\n \"url\": \"\",\n \"user\": {\n \"can_join_groups\": false,\n \"can_read_all_group_messages\": false,\n \"first_name\": \"\",\n \"id\": 0,\n \"is_bot\": false,\n \"language_code\": \"\",\n \"last_name\": \"\",\n \"supports_inline_queries\": false,\n \"username\": \"\"\n }\n }\n ],\n \"parse_mode\": \"\",\n \"reply_markup\": \"\",\n \"reply_to_message_id\": 0,\n \"text\": \"\"\n}")
val request = Request.Builder()
.url("{{baseUrl}}/sendMessage")
.post(body)
.addHeader("content-type", "application/json")
.build()
val response = client.newCall(request).execute()
const http = require('https');
const options = {
method: 'POST',
hostname: 'example.com',
port: null,
path: '/baseUrl/sendMessage',
headers: {
'content-type': 'application/json'
}
};
const req = http.request(options, function (res) {
const chunks = [];
res.on('data', function (chunk) {
chunks.push(chunk);
});
res.on('end', function () {
const body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.write(JSON.stringify({
allow_sending_without_reply: false,
chat_id: '',
disable_notification: false,
disable_web_page_preview: false,
entities: [
{
language: '',
length: 0,
offset: 0,
type: '',
url: '',
user: {
can_join_groups: false,
can_read_all_group_messages: false,
first_name: '',
id: 0,
is_bot: false,
language_code: '',
last_name: '',
supports_inline_queries: false,
username: ''
}
}
],
parse_mode: '',
reply_markup: '',
reply_to_message_id: 0,
text: ''
}));
req.end();
const request = require('request');
const options = {
method: 'POST',
url: '{{baseUrl}}/sendMessage',
headers: {'content-type': 'application/json'},
body: {
allow_sending_without_reply: false,
chat_id: '',
disable_notification: false,
disable_web_page_preview: false,
entities: [
{
language: '',
length: 0,
offset: 0,
type: '',
url: '',
user: {
can_join_groups: false,
can_read_all_group_messages: false,
first_name: '',
id: 0,
is_bot: false,
language_code: '',
last_name: '',
supports_inline_queries: false,
username: ''
}
}
],
parse_mode: '',
reply_markup: '',
reply_to_message_id: 0,
text: ''
},
json: true
};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
const unirest = require('unirest');
const req = unirest('POST', '{{baseUrl}}/sendMessage');
req.headers({
'content-type': 'application/json'
});
req.type('json');
req.send({
allow_sending_without_reply: false,
chat_id: '',
disable_notification: false,
disable_web_page_preview: false,
entities: [
{
language: '',
length: 0,
offset: 0,
type: '',
url: '',
user: {
can_join_groups: false,
can_read_all_group_messages: false,
first_name: '',
id: 0,
is_bot: false,
language_code: '',
last_name: '',
supports_inline_queries: false,
username: ''
}
}
],
parse_mode: '',
reply_markup: '',
reply_to_message_id: 0,
text: ''
});
req.end(function (res) {
if (res.error) throw new Error(res.error);
console.log(res.body);
});
const axios = require('axios').default;
const options = {
method: 'POST',
url: '{{baseUrl}}/sendMessage',
headers: {'content-type': 'application/json'},
data: {
allow_sending_without_reply: false,
chat_id: '',
disable_notification: false,
disable_web_page_preview: false,
entities: [
{
language: '',
length: 0,
offset: 0,
type: '',
url: '',
user: {
can_join_groups: false,
can_read_all_group_messages: false,
first_name: '',
id: 0,
is_bot: false,
language_code: '',
last_name: '',
supports_inline_queries: false,
username: ''
}
}
],
parse_mode: '',
reply_markup: '',
reply_to_message_id: 0,
text: ''
}
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const fetch = require('node-fetch');
const url = '{{baseUrl}}/sendMessage';
const options = {
method: 'POST',
headers: {'content-type': 'application/json'},
body: '{"allow_sending_without_reply":false,"chat_id":"","disable_notification":false,"disable_web_page_preview":false,"entities":[{"language":"","length":0,"offset":0,"type":"","url":"","user":{"can_join_groups":false,"can_read_all_group_messages":false,"first_name":"","id":0,"is_bot":false,"language_code":"","last_name":"","supports_inline_queries":false,"username":""}}],"parse_mode":"","reply_markup":"","reply_to_message_id":0,"text":""}'
};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
#import
NSDictionary *headers = @{ @"content-type": @"application/json" };
NSDictionary *parameters = @{ @"allow_sending_without_reply": @NO,
@"chat_id": @"",
@"disable_notification": @NO,
@"disable_web_page_preview": @NO,
@"entities": @[ @{ @"language": @"", @"length": @0, @"offset": @0, @"type": @"", @"url": @"", @"user": @{ @"can_join_groups": @NO, @"can_read_all_group_messages": @NO, @"first_name": @"", @"id": @0, @"is_bot": @NO, @"language_code": @"", @"last_name": @"", @"supports_inline_queries": @NO, @"username": @"" } } ],
@"parse_mode": @"",
@"reply_markup": @"",
@"reply_to_message_id": @0,
@"text": @"" };
NSData *postData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"{{baseUrl}}/sendMessage"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
[request setHTTPMethod:@"POST"];
[request setAllHTTPHeaderFields:headers];
[request setHTTPBody:postData];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSLog(@"%@", httpResponse);
}
}];
[dataTask resume];
open Cohttp_lwt_unix
open Cohttp
open Lwt
let uri = Uri.of_string "{{baseUrl}}/sendMessage" in
let headers = Header.add (Header.init ()) "content-type" "application/json" in
let body = Cohttp_lwt_body.of_string "{\n \"allow_sending_without_reply\": false,\n \"chat_id\": \"\",\n \"disable_notification\": false,\n \"disable_web_page_preview\": false,\n \"entities\": [\n {\n \"language\": \"\",\n \"length\": 0,\n \"offset\": 0,\n \"type\": \"\",\n \"url\": \"\",\n \"user\": {\n \"can_join_groups\": false,\n \"can_read_all_group_messages\": false,\n \"first_name\": \"\",\n \"id\": 0,\n \"is_bot\": false,\n \"language_code\": \"\",\n \"last_name\": \"\",\n \"supports_inline_queries\": false,\n \"username\": \"\"\n }\n }\n ],\n \"parse_mode\": \"\",\n \"reply_markup\": \"\",\n \"reply_to_message_id\": 0,\n \"text\": \"\"\n}" in
Client.call ~headers ~body `POST uri
>>= fun (res, body_stream) ->
(* Do stuff with the result *)
"{{baseUrl}}/sendMessage",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'allow_sending_without_reply' => null,
'chat_id' => '',
'disable_notification' => null,
'disable_web_page_preview' => null,
'entities' => [
[
'language' => '',
'length' => 0,
'offset' => 0,
'type' => '',
'url' => '',
'user' => [
'can_join_groups' => null,
'can_read_all_group_messages' => null,
'first_name' => '',
'id' => 0,
'is_bot' => null,
'language_code' => '',
'last_name' => '',
'supports_inline_queries' => null,
'username' => ''
]
]
],
'parse_mode' => '',
'reply_markup' => '',
'reply_to_message_id' => 0,
'text' => ''
]),
CURLOPT_HTTPHEADER => [
"content-type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
request('POST', '{{baseUrl}}/sendMessage', [
'body' => '{
"allow_sending_without_reply": false,
"chat_id": "",
"disable_notification": false,
"disable_web_page_preview": false,
"entities": [
{
"language": "",
"length": 0,
"offset": 0,
"type": "",
"url": "",
"user": {
"can_join_groups": false,
"can_read_all_group_messages": false,
"first_name": "",
"id": 0,
"is_bot": false,
"language_code": "",
"last_name": "",
"supports_inline_queries": false,
"username": ""
}
}
],
"parse_mode": "",
"reply_markup": "",
"reply_to_message_id": 0,
"text": ""
}',
'headers' => [
'content-type' => 'application/json',
],
]);
echo $response->getBody();
setUrl('{{baseUrl}}/sendMessage');
$request->setMethod(HTTP_METH_POST);
$request->setHeaders([
'content-type' => 'application/json'
]);
$request->setContentType('application/json');
$request->setBody(json_encode([
'allow_sending_without_reply' => null,
'chat_id' => '',
'disable_notification' => null,
'disable_web_page_preview' => null,
'entities' => [
[
'language' => '',
'length' => 0,
'offset' => 0,
'type' => '',
'url' => '',
'user' => [
'can_join_groups' => null,
'can_read_all_group_messages' => null,
'first_name' => '',
'id' => 0,
'is_bot' => null,
'language_code' => '',
'last_name' => '',
'supports_inline_queries' => null,
'username' => ''
]
]
],
'parse_mode' => '',
'reply_markup' => '',
'reply_to_message_id' => 0,
'text' => ''
]));
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
append(json_encode([
'allow_sending_without_reply' => null,
'chat_id' => '',
'disable_notification' => null,
'disable_web_page_preview' => null,
'entities' => [
[
'language' => '',
'length' => 0,
'offset' => 0,
'type' => '',
'url' => '',
'user' => [
'can_join_groups' => null,
'can_read_all_group_messages' => null,
'first_name' => '',
'id' => 0,
'is_bot' => null,
'language_code' => '',
'last_name' => '',
'supports_inline_queries' => null,
'username' => ''
]
]
],
'parse_mode' => '',
'reply_markup' => '',
'reply_to_message_id' => 0,
'text' => ''
]));
$request->setRequestUrl('{{baseUrl}}/sendMessage');
$request->setRequestMethod('POST');
$request->setBody($body);
$request->setHeaders([
'content-type' => 'application/json'
]);
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
$headers=@{}
$headers.Add("content-type", "application/json")
$response = Invoke-WebRequest -Uri '{{baseUrl}}/sendMessage' -Method POST -Headers $headers -ContentType 'application/json' -Body '{
"allow_sending_without_reply": false,
"chat_id": "",
"disable_notification": false,
"disable_web_page_preview": false,
"entities": [
{
"language": "",
"length": 0,
"offset": 0,
"type": "",
"url": "",
"user": {
"can_join_groups": false,
"can_read_all_group_messages": false,
"first_name": "",
"id": 0,
"is_bot": false,
"language_code": "",
"last_name": "",
"supports_inline_queries": false,
"username": ""
}
}
],
"parse_mode": "",
"reply_markup": "",
"reply_to_message_id": 0,
"text": ""
}'
$headers=@{}
$headers.Add("content-type", "application/json")
$response = Invoke-RestMethod -Uri '{{baseUrl}}/sendMessage' -Method POST -Headers $headers -ContentType 'application/json' -Body '{
"allow_sending_without_reply": false,
"chat_id": "",
"disable_notification": false,
"disable_web_page_preview": false,
"entities": [
{
"language": "",
"length": 0,
"offset": 0,
"type": "",
"url": "",
"user": {
"can_join_groups": false,
"can_read_all_group_messages": false,
"first_name": "",
"id": 0,
"is_bot": false,
"language_code": "",
"last_name": "",
"supports_inline_queries": false,
"username": ""
}
}
],
"parse_mode": "",
"reply_markup": "",
"reply_to_message_id": 0,
"text": ""
}'
import http.client
conn = http.client.HTTPSConnection("example.com")
payload = "{\n \"allow_sending_without_reply\": false,\n \"chat_id\": \"\",\n \"disable_notification\": false,\n \"disable_web_page_preview\": false,\n \"entities\": [\n {\n \"language\": \"\",\n \"length\": 0,\n \"offset\": 0,\n \"type\": \"\",\n \"url\": \"\",\n \"user\": {\n \"can_join_groups\": false,\n \"can_read_all_group_messages\": false,\n \"first_name\": \"\",\n \"id\": 0,\n \"is_bot\": false,\n \"language_code\": \"\",\n \"last_name\": \"\",\n \"supports_inline_queries\": false,\n \"username\": \"\"\n }\n }\n ],\n \"parse_mode\": \"\",\n \"reply_markup\": \"\",\n \"reply_to_message_id\": 0,\n \"text\": \"\"\n}"
headers = { 'content-type': "application/json" }
conn.request("POST", "/baseUrl/sendMessage", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
import requests
url = "{{baseUrl}}/sendMessage"
payload = {
"allow_sending_without_reply": False,
"chat_id": "",
"disable_notification": False,
"disable_web_page_preview": False,
"entities": [
{
"language": "",
"length": 0,
"offset": 0,
"type": "",
"url": "",
"user": {
"can_join_groups": False,
"can_read_all_group_messages": False,
"first_name": "",
"id": 0,
"is_bot": False,
"language_code": "",
"last_name": "",
"supports_inline_queries": False,
"username": ""
}
}
],
"parse_mode": "",
"reply_markup": "",
"reply_to_message_id": 0,
"text": ""
}
headers = {"content-type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
library(httr)
url <- "{{baseUrl}}/sendMessage"
payload <- "{\n \"allow_sending_without_reply\": false,\n \"chat_id\": \"\",\n \"disable_notification\": false,\n \"disable_web_page_preview\": false,\n \"entities\": [\n {\n \"language\": \"\",\n \"length\": 0,\n \"offset\": 0,\n \"type\": \"\",\n \"url\": \"\",\n \"user\": {\n \"can_join_groups\": false,\n \"can_read_all_group_messages\": false,\n \"first_name\": \"\",\n \"id\": 0,\n \"is_bot\": false,\n \"language_code\": \"\",\n \"last_name\": \"\",\n \"supports_inline_queries\": false,\n \"username\": \"\"\n }\n }\n ],\n \"parse_mode\": \"\",\n \"reply_markup\": \"\",\n \"reply_to_message_id\": 0,\n \"text\": \"\"\n}"
encode <- "json"
response <- VERB("POST", url, body = payload, content_type("application/json"), encode = encode)
content(response, "text")
require 'uri'
require 'net/http'
url = URI("{{baseUrl}}/sendMessage")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["content-type"] = 'application/json'
request.body = "{\n \"allow_sending_without_reply\": false,\n \"chat_id\": \"\",\n \"disable_notification\": false,\n \"disable_web_page_preview\": false,\n \"entities\": [\n {\n \"language\": \"\",\n \"length\": 0,\n \"offset\": 0,\n \"type\": \"\",\n \"url\": \"\",\n \"user\": {\n \"can_join_groups\": false,\n \"can_read_all_group_messages\": false,\n \"first_name\": \"\",\n \"id\": 0,\n \"is_bot\": false,\n \"language_code\": \"\",\n \"last_name\": \"\",\n \"supports_inline_queries\": false,\n \"username\": \"\"\n }\n }\n ],\n \"parse_mode\": \"\",\n \"reply_markup\": \"\",\n \"reply_to_message_id\": 0,\n \"text\": \"\"\n}"
response = http.request(request)
puts response.read_body
require 'faraday'
conn = Faraday.new(
url: 'https://example.com',
headers: {'Content-Type' => 'application/json'}
)
response = conn.post('/baseUrl/sendMessage') do |req|
req.body = "{\n \"allow_sending_without_reply\": false,\n \"chat_id\": \"\",\n \"disable_notification\": false,\n \"disable_web_page_preview\": false,\n \"entities\": [\n {\n \"language\": \"\",\n \"length\": 0,\n \"offset\": 0,\n \"type\": \"\",\n \"url\": \"\",\n \"user\": {\n \"can_join_groups\": false,\n \"can_read_all_group_messages\": false,\n \"first_name\": \"\",\n \"id\": 0,\n \"is_bot\": false,\n \"language_code\": \"\",\n \"last_name\": \"\",\n \"supports_inline_queries\": false,\n \"username\": \"\"\n }\n }\n ],\n \"parse_mode\": \"\",\n \"reply_markup\": \"\",\n \"reply_to_message_id\": 0,\n \"text\": \"\"\n}"
end
puts response.status
puts response.body
use serde_json::json;
use reqwest;
#[tokio::main]
pub async fn main() {
let url = "{{baseUrl}}/sendMessage";
let payload = json!({
"allow_sending_without_reply": false,
"chat_id": "",
"disable_notification": false,
"disable_web_page_preview": false,
"entities": (
json!({
"language": "",
"length": 0,
"offset": 0,
"type": "",
"url": "",
"user": json!({
"can_join_groups": false,
"can_read_all_group_messages": false,
"first_name": "",
"id": 0,
"is_bot": false,
"language_code": "",
"last_name": "",
"supports_inline_queries": false,
"username": ""
})
})
),
"parse_mode": "",
"reply_markup": "",
"reply_to_message_id": 0,
"text": ""
});
let mut headers = reqwest::header::HeaderMap::new();
headers.insert("content-type", "application/json".parse().unwrap());
let client = reqwest::Client::new();
let response = client.post(url)
.headers(headers)
.json(&payload)
.send()
.await;
let results = response.unwrap()
.json::()
.await
.unwrap();
dbg!(results);
}
curl --request POST \
--url {{baseUrl}}/sendMessage \
--header 'content-type: application/json' \
--data '{
"allow_sending_without_reply": false,
"chat_id": "",
"disable_notification": false,
"disable_web_page_preview": false,
"entities": [
{
"language": "",
"length": 0,
"offset": 0,
"type": "",
"url": "",
"user": {
"can_join_groups": false,
"can_read_all_group_messages": false,
"first_name": "",
"id": 0,
"is_bot": false,
"language_code": "",
"last_name": "",
"supports_inline_queries": false,
"username": ""
}
}
],
"parse_mode": "",
"reply_markup": "",
"reply_to_message_id": 0,
"text": ""
}'
echo '{
"allow_sending_without_reply": false,
"chat_id": "",
"disable_notification": false,
"disable_web_page_preview": false,
"entities": [
{
"language": "",
"length": 0,
"offset": 0,
"type": "",
"url": "",
"user": {
"can_join_groups": false,
"can_read_all_group_messages": false,
"first_name": "",
"id": 0,
"is_bot": false,
"language_code": "",
"last_name": "",
"supports_inline_queries": false,
"username": ""
}
}
],
"parse_mode": "",
"reply_markup": "",
"reply_to_message_id": 0,
"text": ""
}' | \
http POST {{baseUrl}}/sendMessage \
content-type:application/json
wget --quiet \
--method POST \
--header 'content-type: application/json' \
--body-data '{\n "allow_sending_without_reply": false,\n "chat_id": "",\n "disable_notification": false,\n "disable_web_page_preview": false,\n "entities": [\n {\n "language": "",\n "length": 0,\n "offset": 0,\n "type": "",\n "url": "",\n "user": {\n "can_join_groups": false,\n "can_read_all_group_messages": false,\n "first_name": "",\n "id": 0,\n "is_bot": false,\n "language_code": "",\n "last_name": "",\n "supports_inline_queries": false,\n "username": ""\n }\n }\n ],\n "parse_mode": "",\n "reply_markup": "",\n "reply_to_message_id": 0,\n "text": ""\n}' \
--output-document \
- {{baseUrl}}/sendMessage
import Foundation
let headers = ["content-type": "application/json"]
let parameters = [
"allow_sending_without_reply": false,
"chat_id": "",
"disable_notification": false,
"disable_web_page_preview": false,
"entities": [
[
"language": "",
"length": 0,
"offset": 0,
"type": "",
"url": "",
"user": [
"can_join_groups": false,
"can_read_all_group_messages": false,
"first_name": "",
"id": 0,
"is_bot": false,
"language_code": "",
"last_name": "",
"supports_inline_queries": false,
"username": ""
]
]
],
"parse_mode": "",
"reply_markup": "",
"reply_to_message_id": 0,
"text": ""
] as [String : Any]
let postData = JSONSerialization.data(withJSONObject: parameters, options: [])
let request = NSMutableURLRequest(url: NSURL(string: "{{baseUrl}}/sendMessage")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error as Any)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
POST
Use this method to set a custom title for an administrator in a supergroup promoted by the bot. Returns -True- on success.
{{baseUrl}}/setChatAdministratorCustomTitle
BODY json
{
"chat_id": "",
"custom_title": "",
"user_id": 0
}
Examples
REQUEST
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(hnd, CURLOPT_URL, "{{baseUrl}}/setChatAdministratorCustomTitle");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "content-type: application/json");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "{\n \"chat_id\": \"\",\n \"custom_title\": \"\",\n \"user_id\": 0\n}");
CURLcode ret = curl_easy_perform(hnd);
(require '[clj-http.client :as client])
(client/post "{{baseUrl}}/setChatAdministratorCustomTitle" {:content-type :json
:form-params {:chat_id ""
:custom_title ""
:user_id 0}})
require "http/client"
url = "{{baseUrl}}/setChatAdministratorCustomTitle"
headers = HTTP::Headers{
"content-type" => "application/json"
}
reqBody = "{\n \"chat_id\": \"\",\n \"custom_title\": \"\",\n \"user_id\": 0\n}"
response = HTTP::Client.post url, headers: headers, body: reqBody
puts response.body
using System.Net.Http.Headers;
var client = new HttpClient();
var request = new HttpRequestMessage
{
Method = HttpMethod.Post,
RequestUri = new Uri("{{baseUrl}}/setChatAdministratorCustomTitle"),
Content = new StringContent("{\n \"chat_id\": \"\",\n \"custom_title\": \"\",\n \"user_id\": 0\n}")
{
Headers =
{
ContentType = new MediaTypeHeaderValue("application/json")
}
}
};
using (var response = await client.SendAsync(request))
{
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
}
var client = new RestClient("{{baseUrl}}/setChatAdministratorCustomTitle");
var request = new RestRequest("", Method.Post);
request.AddHeader("content-type", "application/json");
request.AddParameter("application/json", "{\n \"chat_id\": \"\",\n \"custom_title\": \"\",\n \"user_id\": 0\n}", ParameterType.RequestBody);
var response = client.Execute(request);
package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "{{baseUrl}}/setChatAdministratorCustomTitle"
payload := strings.NewReader("{\n \"chat_id\": \"\",\n \"custom_title\": \"\",\n \"user_id\": 0\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("content-type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
POST /baseUrl/setChatAdministratorCustomTitle HTTP/1.1
Content-Type: application/json
Host: example.com
Content-Length: 57
{
"chat_id": "",
"custom_title": "",
"user_id": 0
}
AsyncHttpClient client = new DefaultAsyncHttpClient();
client.prepare("POST", "{{baseUrl}}/setChatAdministratorCustomTitle")
.setHeader("content-type", "application/json")
.setBody("{\n \"chat_id\": \"\",\n \"custom_title\": \"\",\n \"user_id\": 0\n}")
.execute()
.toCompletableFuture()
.thenAccept(System.out::println)
.join();
client.close();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("{{baseUrl}}/setChatAdministratorCustomTitle"))
.header("content-type", "application/json")
.method("POST", HttpRequest.BodyPublishers.ofString("{\n \"chat_id\": \"\",\n \"custom_title\": \"\",\n \"user_id\": 0\n}"))
.build();
HttpResponse response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n \"chat_id\": \"\",\n \"custom_title\": \"\",\n \"user_id\": 0\n}");
Request request = new Request.Builder()
.url("{{baseUrl}}/setChatAdministratorCustomTitle")
.post(body)
.addHeader("content-type", "application/json")
.build();
Response response = client.newCall(request).execute();
HttpResponse response = Unirest.post("{{baseUrl}}/setChatAdministratorCustomTitle")
.header("content-type", "application/json")
.body("{\n \"chat_id\": \"\",\n \"custom_title\": \"\",\n \"user_id\": 0\n}")
.asString();
const data = JSON.stringify({
chat_id: '',
custom_title: '',
user_id: 0
});
const xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener('readystatechange', function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open('POST', '{{baseUrl}}/setChatAdministratorCustomTitle');
xhr.setRequestHeader('content-type', 'application/json');
xhr.send(data);
import axios from 'axios';
const options = {
method: 'POST',
url: '{{baseUrl}}/setChatAdministratorCustomTitle',
headers: {'content-type': 'application/json'},
data: {chat_id: '', custom_title: '', user_id: 0}
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const url = '{{baseUrl}}/setChatAdministratorCustomTitle';
const options = {
method: 'POST',
headers: {'content-type': 'application/json'},
body: '{"chat_id":"","custom_title":"","user_id":0}'
};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
const settings = {
async: true,
crossDomain: true,
url: '{{baseUrl}}/setChatAdministratorCustomTitle',
method: 'POST',
headers: {
'content-type': 'application/json'
},
processData: false,
data: '{\n "chat_id": "",\n "custom_title": "",\n "user_id": 0\n}'
};
$.ajax(settings).done(function (response) {
console.log(response);
});
val client = OkHttpClient()
val mediaType = MediaType.parse("application/json")
val body = RequestBody.create(mediaType, "{\n \"chat_id\": \"\",\n \"custom_title\": \"\",\n \"user_id\": 0\n}")
val request = Request.Builder()
.url("{{baseUrl}}/setChatAdministratorCustomTitle")
.post(body)
.addHeader("content-type", "application/json")
.build()
val response = client.newCall(request).execute()
const http = require('https');
const options = {
method: 'POST',
hostname: 'example.com',
port: null,
path: '/baseUrl/setChatAdministratorCustomTitle',
headers: {
'content-type': 'application/json'
}
};
const req = http.request(options, function (res) {
const chunks = [];
res.on('data', function (chunk) {
chunks.push(chunk);
});
res.on('end', function () {
const body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.write(JSON.stringify({chat_id: '', custom_title: '', user_id: 0}));
req.end();
const request = require('request');
const options = {
method: 'POST',
url: '{{baseUrl}}/setChatAdministratorCustomTitle',
headers: {'content-type': 'application/json'},
body: {chat_id: '', custom_title: '', user_id: 0},
json: true
};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
const unirest = require('unirest');
const req = unirest('POST', '{{baseUrl}}/setChatAdministratorCustomTitle');
req.headers({
'content-type': 'application/json'
});
req.type('json');
req.send({
chat_id: '',
custom_title: '',
user_id: 0
});
req.end(function (res) {
if (res.error) throw new Error(res.error);
console.log(res.body);
});
const axios = require('axios').default;
const options = {
method: 'POST',
url: '{{baseUrl}}/setChatAdministratorCustomTitle',
headers: {'content-type': 'application/json'},
data: {chat_id: '', custom_title: '', user_id: 0}
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const fetch = require('node-fetch');
const url = '{{baseUrl}}/setChatAdministratorCustomTitle';
const options = {
method: 'POST',
headers: {'content-type': 'application/json'},
body: '{"chat_id":"","custom_title":"","user_id":0}'
};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
#import
NSDictionary *headers = @{ @"content-type": @"application/json" };
NSDictionary *parameters = @{ @"chat_id": @"",
@"custom_title": @"",
@"user_id": @0 };
NSData *postData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"{{baseUrl}}/setChatAdministratorCustomTitle"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
[request setHTTPMethod:@"POST"];
[request setAllHTTPHeaderFields:headers];
[request setHTTPBody:postData];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSLog(@"%@", httpResponse);
}
}];
[dataTask resume];
open Cohttp_lwt_unix
open Cohttp
open Lwt
let uri = Uri.of_string "{{baseUrl}}/setChatAdministratorCustomTitle" in
let headers = Header.add (Header.init ()) "content-type" "application/json" in
let body = Cohttp_lwt_body.of_string "{\n \"chat_id\": \"\",\n \"custom_title\": \"\",\n \"user_id\": 0\n}" in
Client.call ~headers ~body `POST uri
>>= fun (res, body_stream) ->
(* Do stuff with the result *)
"{{baseUrl}}/setChatAdministratorCustomTitle",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'chat_id' => '',
'custom_title' => '',
'user_id' => 0
]),
CURLOPT_HTTPHEADER => [
"content-type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
request('POST', '{{baseUrl}}/setChatAdministratorCustomTitle', [
'body' => '{
"chat_id": "",
"custom_title": "",
"user_id": 0
}',
'headers' => [
'content-type' => 'application/json',
],
]);
echo $response->getBody();
setUrl('{{baseUrl}}/setChatAdministratorCustomTitle');
$request->setMethod(HTTP_METH_POST);
$request->setHeaders([
'content-type' => 'application/json'
]);
$request->setContentType('application/json');
$request->setBody(json_encode([
'chat_id' => '',
'custom_title' => '',
'user_id' => 0
]));
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
append(json_encode([
'chat_id' => '',
'custom_title' => '',
'user_id' => 0
]));
$request->setRequestUrl('{{baseUrl}}/setChatAdministratorCustomTitle');
$request->setRequestMethod('POST');
$request->setBody($body);
$request->setHeaders([
'content-type' => 'application/json'
]);
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
$headers=@{}
$headers.Add("content-type", "application/json")
$response = Invoke-WebRequest -Uri '{{baseUrl}}/setChatAdministratorCustomTitle' -Method POST -Headers $headers -ContentType 'application/json' -Body '{
"chat_id": "",
"custom_title": "",
"user_id": 0
}'
$headers=@{}
$headers.Add("content-type", "application/json")
$response = Invoke-RestMethod -Uri '{{baseUrl}}/setChatAdministratorCustomTitle' -Method POST -Headers $headers -ContentType 'application/json' -Body '{
"chat_id": "",
"custom_title": "",
"user_id": 0
}'
import http.client
conn = http.client.HTTPSConnection("example.com")
payload = "{\n \"chat_id\": \"\",\n \"custom_title\": \"\",\n \"user_id\": 0\n}"
headers = { 'content-type': "application/json" }
conn.request("POST", "/baseUrl/setChatAdministratorCustomTitle", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
import requests
url = "{{baseUrl}}/setChatAdministratorCustomTitle"
payload = {
"chat_id": "",
"custom_title": "",
"user_id": 0
}
headers = {"content-type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
library(httr)
url <- "{{baseUrl}}/setChatAdministratorCustomTitle"
payload <- "{\n \"chat_id\": \"\",\n \"custom_title\": \"\",\n \"user_id\": 0\n}"
encode <- "json"
response <- VERB("POST", url, body = payload, content_type("application/json"), encode = encode)
content(response, "text")
require 'uri'
require 'net/http'
url = URI("{{baseUrl}}/setChatAdministratorCustomTitle")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["content-type"] = 'application/json'
request.body = "{\n \"chat_id\": \"\",\n \"custom_title\": \"\",\n \"user_id\": 0\n}"
response = http.request(request)
puts response.read_body
require 'faraday'
conn = Faraday.new(
url: 'https://example.com',
headers: {'Content-Type' => 'application/json'}
)
response = conn.post('/baseUrl/setChatAdministratorCustomTitle') do |req|
req.body = "{\n \"chat_id\": \"\",\n \"custom_title\": \"\",\n \"user_id\": 0\n}"
end
puts response.status
puts response.body
use serde_json::json;
use reqwest;
#[tokio::main]
pub async fn main() {
let url = "{{baseUrl}}/setChatAdministratorCustomTitle";
let payload = json!({
"chat_id": "",
"custom_title": "",
"user_id": 0
});
let mut headers = reqwest::header::HeaderMap::new();
headers.insert("content-type", "application/json".parse().unwrap());
let client = reqwest::Client::new();
let response = client.post(url)
.headers(headers)
.json(&payload)
.send()
.await;
let results = response.unwrap()
.json::()
.await
.unwrap();
dbg!(results);
}
curl --request POST \
--url {{baseUrl}}/setChatAdministratorCustomTitle \
--header 'content-type: application/json' \
--data '{
"chat_id": "",
"custom_title": "",
"user_id": 0
}'
echo '{
"chat_id": "",
"custom_title": "",
"user_id": 0
}' | \
http POST {{baseUrl}}/setChatAdministratorCustomTitle \
content-type:application/json
wget --quiet \
--method POST \
--header 'content-type: application/json' \
--body-data '{\n "chat_id": "",\n "custom_title": "",\n "user_id": 0\n}' \
--output-document \
- {{baseUrl}}/setChatAdministratorCustomTitle
import Foundation
let headers = ["content-type": "application/json"]
let parameters = [
"chat_id": "",
"custom_title": "",
"user_id": 0
] as [String : Any]
let postData = JSONSerialization.data(withJSONObject: parameters, options: [])
let request = NSMutableURLRequest(url: NSURL(string: "{{baseUrl}}/setChatAdministratorCustomTitle")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error as Any)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
POST
Use this method to set a new profile photo for the chat. Photos can't be changed for private chats. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Returns -True- on success.
{{baseUrl}}/setChatPhoto
BODY multipartForm
Examples
REQUEST
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(hnd, CURLOPT_URL, "{{baseUrl}}/setChatPhoto");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "content-type: multipart/form-data; boundary=---011000010111000001101001");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"chat_id\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"photo\"\r\n\r\n\r\n-----011000010111000001101001--\r\n");
CURLcode ret = curl_easy_perform(hnd);
(require '[clj-http.client :as client])
(client/post "{{baseUrl}}/setChatPhoto" {:multipart [{:name "chat_id"
:content ""} {:name "photo"
:content ""}]})
require "http/client"
url = "{{baseUrl}}/setChatPhoto"
headers = HTTP::Headers{
"content-type" => "multipart/form-data; boundary=---011000010111000001101001"
}
reqBody = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"chat_id\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"photo\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"
response = HTTP::Client.post url, headers: headers, body: reqBody
puts response.body
using System.Net.Http.Headers;
var client = new HttpClient();
var request = new HttpRequestMessage
{
Method = HttpMethod.Post,
RequestUri = new Uri("{{baseUrl}}/setChatPhoto"),
Content = new MultipartFormDataContent
{
new StringContent("")
{
Headers =
{
ContentDisposition = new ContentDispositionHeaderValue("form-data")
{
Name = "chat_id",
}
}
},
new StringContent("")
{
Headers =
{
ContentDisposition = new ContentDispositionHeaderValue("form-data")
{
Name = "photo",
}
}
},
},
};
using (var response = await client.SendAsync(request))
{
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
}
var client = new RestClient("{{baseUrl}}/setChatPhoto");
var request = new RestRequest("", Method.Post);
request.AddHeader("content-type", "multipart/form-data; boundary=---011000010111000001101001");
request.AddParameter("multipart/form-data; boundary=---011000010111000001101001", "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"chat_id\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"photo\"\r\n\r\n\r\n-----011000010111000001101001--\r\n", ParameterType.RequestBody);
var response = client.Execute(request);
package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "{{baseUrl}}/setChatPhoto"
payload := strings.NewReader("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"chat_id\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"photo\"\r\n\r\n\r\n-----011000010111000001101001--\r\n")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("content-type", "multipart/form-data; boundary=---011000010111000001101001")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
POST /baseUrl/setChatPhoto HTTP/1.1
Content-Type: multipart/form-data; boundary=---011000010111000001101001
Host: example.com
Content-Length: 197
-----011000010111000001101001
Content-Disposition: form-data; name="chat_id"
-----011000010111000001101001
Content-Disposition: form-data; name="photo"
-----011000010111000001101001--
AsyncHttpClient client = new DefaultAsyncHttpClient();
client.prepare("POST", "{{baseUrl}}/setChatPhoto")
.setHeader("content-type", "multipart/form-data; boundary=---011000010111000001101001")
.setBody("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"chat_id\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"photo\"\r\n\r\n\r\n-----011000010111000001101001--\r\n")
.execute()
.toCompletableFuture()
.thenAccept(System.out::println)
.join();
client.close();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("{{baseUrl}}/setChatPhoto"))
.header("content-type", "multipart/form-data; boundary=---011000010111000001101001")
.method("POST", HttpRequest.BodyPublishers.ofString("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"chat_id\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"photo\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"))
.build();
HttpResponse response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("multipart/form-data; boundary=---011000010111000001101001");
RequestBody body = RequestBody.create(mediaType, "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"chat_id\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"photo\"\r\n\r\n\r\n-----011000010111000001101001--\r\n");
Request request = new Request.Builder()
.url("{{baseUrl}}/setChatPhoto")
.post(body)
.addHeader("content-type", "multipart/form-data; boundary=---011000010111000001101001")
.build();
Response response = client.newCall(request).execute();
HttpResponse response = Unirest.post("{{baseUrl}}/setChatPhoto")
.header("content-type", "multipart/form-data; boundary=---011000010111000001101001")
.body("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"chat_id\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"photo\"\r\n\r\n\r\n-----011000010111000001101001--\r\n")
.asString();
const data = new FormData();
data.append('chat_id', '');
data.append('photo', '');
const xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener('readystatechange', function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open('POST', '{{baseUrl}}/setChatPhoto');
xhr.send(data);
import axios from 'axios';
const form = new FormData();
form.append('chat_id', '');
form.append('photo', '');
const options = {
method: 'POST',
url: '{{baseUrl}}/setChatPhoto',
headers: {'content-type': 'multipart/form-data; boundary=---011000010111000001101001'},
data: '[form]'
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const url = '{{baseUrl}}/setChatPhoto';
const form = new FormData();
form.append('chat_id', '');
form.append('photo', '');
const options = {method: 'POST'};
options.body = form;
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
const form = new FormData();
form.append('chat_id', '');
form.append('photo', '');
const settings = {
async: true,
crossDomain: true,
url: '{{baseUrl}}/setChatPhoto',
method: 'POST',
headers: {},
processData: false,
contentType: false,
mimeType: 'multipart/form-data',
data: form
};
$.ajax(settings).done(function (response) {
console.log(response);
});
val client = OkHttpClient()
val mediaType = MediaType.parse("multipart/form-data; boundary=---011000010111000001101001")
val body = RequestBody.create(mediaType, "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"chat_id\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"photo\"\r\n\r\n\r\n-----011000010111000001101001--\r\n")
val request = Request.Builder()
.url("{{baseUrl}}/setChatPhoto")
.post(body)
.addHeader("content-type", "multipart/form-data; boundary=---011000010111000001101001")
.build()
val response = client.newCall(request).execute()
const http = require('https');
const options = {
method: 'POST',
hostname: 'example.com',
port: null,
path: '/baseUrl/setChatPhoto',
headers: {
'content-type': 'multipart/form-data; boundary=---011000010111000001101001'
}
};
const req = http.request(options, function (res) {
const chunks = [];
res.on('data', function (chunk) {
chunks.push(chunk);
});
res.on('end', function () {
const body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.write('-----011000010111000001101001\r\nContent-Disposition: form-data; name="chat_id"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name="photo"\r\n\r\n\r\n-----011000010111000001101001--\r\n');
req.end();
const request = require('request');
const options = {
method: 'POST',
url: '{{baseUrl}}/setChatPhoto',
headers: {'content-type': 'multipart/form-data; boundary=---011000010111000001101001'},
formData: {chat_id: '', photo: ''}
};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
const unirest = require('unirest');
const req = unirest('POST', '{{baseUrl}}/setChatPhoto');
req.headers({
'content-type': 'multipart/form-data; boundary=---011000010111000001101001'
});
req.multipart([]);
req.end(function (res) {
if (res.error) throw new Error(res.error);
console.log(res.body);
});
const axios = require('axios').default;
const options = {
method: 'POST',
url: '{{baseUrl}}/setChatPhoto',
headers: {'content-type': 'multipart/form-data; boundary=---011000010111000001101001'},
data: '-----011000010111000001101001\r\nContent-Disposition: form-data; name="chat_id"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name="photo"\r\n\r\n\r\n-----011000010111000001101001--\r\n'
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const FormData = require('form-data');
const fetch = require('node-fetch');
const formData = new FormData();
formData.append('chat_id', '');
formData.append('photo', '');
const url = '{{baseUrl}}/setChatPhoto';
const options = {method: 'POST'};
options.body = formData;
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
#import
NSDictionary *headers = @{ @"content-type": @"multipart/form-data; boundary=---011000010111000001101001" };
NSArray *parameters = @[ @{ @"name": @"chat_id", @"value": @"" },
@{ @"name": @"photo", @"value": @"" } ];
NSString *boundary = @"---011000010111000001101001";
NSError *error;
NSMutableString *body = [NSMutableString string];
for (NSDictionary *param in parameters) {
[body appendFormat:@"--%@\r\n", boundary];
if (param[@"fileName"]) {
[body appendFormat:@"Content-Disposition:form-data; name=\"%@\"; filename=\"%@\"\r\n", param[@"name"], param[@"fileName"]];
[body appendFormat:@"Content-Type: %@\r\n\r\n", param[@"contentType"]];
[body appendFormat:@"%@", [NSString stringWithContentsOfFile:param[@"fileName"] encoding:NSUTF8StringEncoding error:&error]];
if (error) {
NSLog(@"%@", error);
}
} else {
[body appendFormat:@"Content-Disposition:form-data; name=\"%@\"\r\n\r\n", param[@"name"]];
[body appendFormat:@"%@", param[@"value"]];
}
}
[body appendFormat:@"\r\n--%@--\r\n", boundary];
NSData *postData = [body dataUsingEncoding:NSUTF8StringEncoding];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"{{baseUrl}}/setChatPhoto"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
[request setHTTPMethod:@"POST"];
[request setAllHTTPHeaderFields:headers];
[request setHTTPBody:postData];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSLog(@"%@", httpResponse);
}
}];
[dataTask resume];
open Cohttp_lwt_unix
open Cohttp
open Lwt
let uri = Uri.of_string "{{baseUrl}}/setChatPhoto" in
let headers = Header.add (Header.init ()) "content-type" "multipart/form-data; boundary=---011000010111000001101001" in
let body = Cohttp_lwt_body.of_string "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"chat_id\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"photo\"\r\n\r\n\r\n-----011000010111000001101001--\r\n" in
Client.call ~headers ~body `POST uri
>>= fun (res, body_stream) ->
(* Do stuff with the result *)
"{{baseUrl}}/setChatPhoto",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"chat_id\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"photo\"\r\n\r\n\r\n-----011000010111000001101001--\r\n",
CURLOPT_HTTPHEADER => [
"content-type: multipart/form-data; boundary=---011000010111000001101001"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
request('POST', '{{baseUrl}}/setChatPhoto', [
'headers' => [
'content-type' => 'multipart/form-data; boundary=---011000010111000001101001',
],
]);
echo $response->getBody();
setUrl('{{baseUrl}}/setChatPhoto');
$request->setMethod(HTTP_METH_POST);
$request->setHeaders([
'content-type' => 'multipart/form-data; boundary=---011000010111000001101001'
]);
$request->setBody('-----011000010111000001101001
Content-Disposition: form-data; name="chat_id"
-----011000010111000001101001
Content-Disposition: form-data; name="photo"
-----011000010111000001101001--
');
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
addForm(null, null);
$request->setRequestUrl('{{baseUrl}}/setChatPhoto');
$request->setRequestMethod('POST');
$request->setBody($body);
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
$headers=@{}
$headers.Add("content-type", "multipart/form-data; boundary=---011000010111000001101001")
$response = Invoke-WebRequest -Uri '{{baseUrl}}/setChatPhoto' -Method POST -Headers $headers -ContentType 'multipart/form-data; boundary=---011000010111000001101001' -Body '-----011000010111000001101001
Content-Disposition: form-data; name="chat_id"
-----011000010111000001101001
Content-Disposition: form-data; name="photo"
-----011000010111000001101001--
'
$headers=@{}
$headers.Add("content-type", "multipart/form-data; boundary=---011000010111000001101001")
$response = Invoke-RestMethod -Uri '{{baseUrl}}/setChatPhoto' -Method POST -Headers $headers -ContentType 'multipart/form-data; boundary=---011000010111000001101001' -Body '-----011000010111000001101001
Content-Disposition: form-data; name="chat_id"
-----011000010111000001101001
Content-Disposition: form-data; name="photo"
-----011000010111000001101001--
'
import http.client
conn = http.client.HTTPSConnection("example.com")
payload = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"chat_id\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"photo\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"
headers = { 'content-type': "multipart/form-data; boundary=---011000010111000001101001" }
conn.request("POST", "/baseUrl/setChatPhoto", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
import requests
url = "{{baseUrl}}/setChatPhoto"
payload = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"chat_id\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"photo\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"
headers = {"content-type": "multipart/form-data; boundary=---011000010111000001101001"}
response = requests.post(url, data=payload, headers=headers)
print(response.json())
library(httr)
url <- "{{baseUrl}}/setChatPhoto"
payload <- "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"chat_id\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"photo\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"
encode <- "multipart"
response <- VERB("POST", url, body = payload, content_type("multipart/form-data"), encode = encode)
content(response, "text")
require 'uri'
require 'net/http'
url = URI("{{baseUrl}}/setChatPhoto")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["content-type"] = 'multipart/form-data; boundary=---011000010111000001101001'
request.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"chat_id\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"photo\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"
response = http.request(request)
puts response.read_body
require 'faraday'
conn = Faraday.new(
url: 'https://example.com',
headers: {'Content-Type' => 'multipart/form-data; boundary=---011000010111000001101001'}
)
response = conn.post('/baseUrl/setChatPhoto') do |req|
req.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"chat_id\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"photo\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"
end
puts response.status
puts response.body
use reqwest;
#[tokio::main]
pub async fn main() {
let url = "{{baseUrl}}/setChatPhoto";
let form = reqwest::multipart::Form::new()
.text("chat_id", "")
.text("photo", "");
let mut headers = reqwest::header::HeaderMap::new();
let client = reqwest::Client::new();
let response = client.post(url)
.multipart(form)
.headers(headers)
.send()
.await;
let results = response.unwrap()
.json::()
.await
.unwrap();
dbg!(results);
}
curl --request POST \
--url {{baseUrl}}/setChatPhoto \
--header 'content-type: multipart/form-data' \
--form chat_id= \
--form photo=
echo '-----011000010111000001101001
Content-Disposition: form-data; name="chat_id"
-----011000010111000001101001
Content-Disposition: form-data; name="photo"
-----011000010111000001101001--
' | \
http POST {{baseUrl}}/setChatPhoto \
content-type:'multipart/form-data; boundary=---011000010111000001101001'
wget --quiet \
--method POST \
--header 'content-type: multipart/form-data; boundary=---011000010111000001101001' \
--body-data '-----011000010111000001101001\r\nContent-Disposition: form-data; name="chat_id"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name="photo"\r\n\r\n\r\n-----011000010111000001101001--\r\n' \
--output-document \
- {{baseUrl}}/setChatPhoto
import Foundation
let headers = ["content-type": "multipart/form-data; boundary=---011000010111000001101001"]
let parameters = [
[
"name": "chat_id",
"value": ""
],
[
"name": "photo",
"value": ""
]
]
let boundary = "---011000010111000001101001"
var body = ""
var error: NSError? = nil
for param in parameters {
let paramName = param["name"]!
body += "--\(boundary)\r\n"
body += "Content-Disposition:form-data; name=\"\(paramName)\""
if let filename = param["fileName"] {
let contentType = param["content-type"]!
let fileContent = String(contentsOfFile: filename, encoding: String.Encoding.utf8)
if (error != nil) {
print(error as Any)
}
body += "; filename=\"\(filename)\"\r\n"
body += "Content-Type: \(contentType)\r\n\r\n"
body += fileContent
} else if let paramValue = param["value"] {
body += "\r\n\r\n\(paramValue)"
}
}
let request = NSMutableURLRequest(url: NSURL(string: "{{baseUrl}}/setChatPhoto")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error as Any)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
POST
Use this method to set default chat permissions for all members. The bot must be an administrator in the group or a supergroup for this to work and must have the -can-_restrict-_members- admin rights. Returns -True- on success.
{{baseUrl}}/setChatPermissions
BODY json
{
"chat_id": "",
"permissions": {
"can_add_web_page_previews": false,
"can_change_info": false,
"can_invite_users": false,
"can_pin_messages": false,
"can_send_media_messages": false,
"can_send_messages": false,
"can_send_other_messages": false,
"can_send_polls": false
}
}
Examples
REQUEST
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(hnd, CURLOPT_URL, "{{baseUrl}}/setChatPermissions");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "content-type: application/json");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "{\n \"chat_id\": \"\",\n \"permissions\": {\n \"can_add_web_page_previews\": false,\n \"can_change_info\": false,\n \"can_invite_users\": false,\n \"can_pin_messages\": false,\n \"can_send_media_messages\": false,\n \"can_send_messages\": false,\n \"can_send_other_messages\": false,\n \"can_send_polls\": false\n }\n}");
CURLcode ret = curl_easy_perform(hnd);
(require '[clj-http.client :as client])
(client/post "{{baseUrl}}/setChatPermissions" {:content-type :json
:form-params {:chat_id ""
:permissions {:can_add_web_page_previews false
:can_change_info false
:can_invite_users false
:can_pin_messages false
:can_send_media_messages false
:can_send_messages false
:can_send_other_messages false
:can_send_polls false}}})
require "http/client"
url = "{{baseUrl}}/setChatPermissions"
headers = HTTP::Headers{
"content-type" => "application/json"
}
reqBody = "{\n \"chat_id\": \"\",\n \"permissions\": {\n \"can_add_web_page_previews\": false,\n \"can_change_info\": false,\n \"can_invite_users\": false,\n \"can_pin_messages\": false,\n \"can_send_media_messages\": false,\n \"can_send_messages\": false,\n \"can_send_other_messages\": false,\n \"can_send_polls\": false\n }\n}"
response = HTTP::Client.post url, headers: headers, body: reqBody
puts response.body
using System.Net.Http.Headers;
var client = new HttpClient();
var request = new HttpRequestMessage
{
Method = HttpMethod.Post,
RequestUri = new Uri("{{baseUrl}}/setChatPermissions"),
Content = new StringContent("{\n \"chat_id\": \"\",\n \"permissions\": {\n \"can_add_web_page_previews\": false,\n \"can_change_info\": false,\n \"can_invite_users\": false,\n \"can_pin_messages\": false,\n \"can_send_media_messages\": false,\n \"can_send_messages\": false,\n \"can_send_other_messages\": false,\n \"can_send_polls\": false\n }\n}")
{
Headers =
{
ContentType = new MediaTypeHeaderValue("application/json")
}
}
};
using (var response = await client.SendAsync(request))
{
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
}
var client = new RestClient("{{baseUrl}}/setChatPermissions");
var request = new RestRequest("", Method.Post);
request.AddHeader("content-type", "application/json");
request.AddParameter("application/json", "{\n \"chat_id\": \"\",\n \"permissions\": {\n \"can_add_web_page_previews\": false,\n \"can_change_info\": false,\n \"can_invite_users\": false,\n \"can_pin_messages\": false,\n \"can_send_media_messages\": false,\n \"can_send_messages\": false,\n \"can_send_other_messages\": false,\n \"can_send_polls\": false\n }\n}", ParameterType.RequestBody);
var response = client.Execute(request);
package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "{{baseUrl}}/setChatPermissions"
payload := strings.NewReader("{\n \"chat_id\": \"\",\n \"permissions\": {\n \"can_add_web_page_previews\": false,\n \"can_change_info\": false,\n \"can_invite_users\": false,\n \"can_pin_messages\": false,\n \"can_send_media_messages\": false,\n \"can_send_messages\": false,\n \"can_send_other_messages\": false,\n \"can_send_polls\": false\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("content-type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
POST /baseUrl/setChatPermissions HTTP/1.1
Content-Type: application/json
Host: example.com
Content-Length: 311
{
"chat_id": "",
"permissions": {
"can_add_web_page_previews": false,
"can_change_info": false,
"can_invite_users": false,
"can_pin_messages": false,
"can_send_media_messages": false,
"can_send_messages": false,
"can_send_other_messages": false,
"can_send_polls": false
}
}
AsyncHttpClient client = new DefaultAsyncHttpClient();
client.prepare("POST", "{{baseUrl}}/setChatPermissions")
.setHeader("content-type", "application/json")
.setBody("{\n \"chat_id\": \"\",\n \"permissions\": {\n \"can_add_web_page_previews\": false,\n \"can_change_info\": false,\n \"can_invite_users\": false,\n \"can_pin_messages\": false,\n \"can_send_media_messages\": false,\n \"can_send_messages\": false,\n \"can_send_other_messages\": false,\n \"can_send_polls\": false\n }\n}")
.execute()
.toCompletableFuture()
.thenAccept(System.out::println)
.join();
client.close();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("{{baseUrl}}/setChatPermissions"))
.header("content-type", "application/json")
.method("POST", HttpRequest.BodyPublishers.ofString("{\n \"chat_id\": \"\",\n \"permissions\": {\n \"can_add_web_page_previews\": false,\n \"can_change_info\": false,\n \"can_invite_users\": false,\n \"can_pin_messages\": false,\n \"can_send_media_messages\": false,\n \"can_send_messages\": false,\n \"can_send_other_messages\": false,\n \"can_send_polls\": false\n }\n}"))
.build();
HttpResponse response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n \"chat_id\": \"\",\n \"permissions\": {\n \"can_add_web_page_previews\": false,\n \"can_change_info\": false,\n \"can_invite_users\": false,\n \"can_pin_messages\": false,\n \"can_send_media_messages\": false,\n \"can_send_messages\": false,\n \"can_send_other_messages\": false,\n \"can_send_polls\": false\n }\n}");
Request request = new Request.Builder()
.url("{{baseUrl}}/setChatPermissions")
.post(body)
.addHeader("content-type", "application/json")
.build();
Response response = client.newCall(request).execute();
HttpResponse response = Unirest.post("{{baseUrl}}/setChatPermissions")
.header("content-type", "application/json")
.body("{\n \"chat_id\": \"\",\n \"permissions\": {\n \"can_add_web_page_previews\": false,\n \"can_change_info\": false,\n \"can_invite_users\": false,\n \"can_pin_messages\": false,\n \"can_send_media_messages\": false,\n \"can_send_messages\": false,\n \"can_send_other_messages\": false,\n \"can_send_polls\": false\n }\n}")
.asString();
const data = JSON.stringify({
chat_id: '',
permissions: {
can_add_web_page_previews: false,
can_change_info: false,
can_invite_users: false,
can_pin_messages: false,
can_send_media_messages: false,
can_send_messages: false,
can_send_other_messages: false,
can_send_polls: false
}
});
const xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener('readystatechange', function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open('POST', '{{baseUrl}}/setChatPermissions');
xhr.setRequestHeader('content-type', 'application/json');
xhr.send(data);
import axios from 'axios';
const options = {
method: 'POST',
url: '{{baseUrl}}/setChatPermissions',
headers: {'content-type': 'application/json'},
data: {
chat_id: '',
permissions: {
can_add_web_page_previews: false,
can_change_info: false,
can_invite_users: false,
can_pin_messages: false,
can_send_media_messages: false,
can_send_messages: false,
can_send_other_messages: false,
can_send_polls: false
}
}
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const url = '{{baseUrl}}/setChatPermissions';
const options = {
method: 'POST',
headers: {'content-type': 'application/json'},
body: '{"chat_id":"","permissions":{"can_add_web_page_previews":false,"can_change_info":false,"can_invite_users":false,"can_pin_messages":false,"can_send_media_messages":false,"can_send_messages":false,"can_send_other_messages":false,"can_send_polls":false}}'
};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
const settings = {
async: true,
crossDomain: true,
url: '{{baseUrl}}/setChatPermissions',
method: 'POST',
headers: {
'content-type': 'application/json'
},
processData: false,
data: '{\n "chat_id": "",\n "permissions": {\n "can_add_web_page_previews": false,\n "can_change_info": false,\n "can_invite_users": false,\n "can_pin_messages": false,\n "can_send_media_messages": false,\n "can_send_messages": false,\n "can_send_other_messages": false,\n "can_send_polls": false\n }\n}'
};
$.ajax(settings).done(function (response) {
console.log(response);
});
val client = OkHttpClient()
val mediaType = MediaType.parse("application/json")
val body = RequestBody.create(mediaType, "{\n \"chat_id\": \"\",\n \"permissions\": {\n \"can_add_web_page_previews\": false,\n \"can_change_info\": false,\n \"can_invite_users\": false,\n \"can_pin_messages\": false,\n \"can_send_media_messages\": false,\n \"can_send_messages\": false,\n \"can_send_other_messages\": false,\n \"can_send_polls\": false\n }\n}")
val request = Request.Builder()
.url("{{baseUrl}}/setChatPermissions")
.post(body)
.addHeader("content-type", "application/json")
.build()
val response = client.newCall(request).execute()
const http = require('https');
const options = {
method: 'POST',
hostname: 'example.com',
port: null,
path: '/baseUrl/setChatPermissions',
headers: {
'content-type': 'application/json'
}
};
const req = http.request(options, function (res) {
const chunks = [];
res.on('data', function (chunk) {
chunks.push(chunk);
});
res.on('end', function () {
const body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.write(JSON.stringify({
chat_id: '',
permissions: {
can_add_web_page_previews: false,
can_change_info: false,
can_invite_users: false,
can_pin_messages: false,
can_send_media_messages: false,
can_send_messages: false,
can_send_other_messages: false,
can_send_polls: false
}
}));
req.end();
const request = require('request');
const options = {
method: 'POST',
url: '{{baseUrl}}/setChatPermissions',
headers: {'content-type': 'application/json'},
body: {
chat_id: '',
permissions: {
can_add_web_page_previews: false,
can_change_info: false,
can_invite_users: false,
can_pin_messages: false,
can_send_media_messages: false,
can_send_messages: false,
can_send_other_messages: false,
can_send_polls: false
}
},
json: true
};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
const unirest = require('unirest');
const req = unirest('POST', '{{baseUrl}}/setChatPermissions');
req.headers({
'content-type': 'application/json'
});
req.type('json');
req.send({
chat_id: '',
permissions: {
can_add_web_page_previews: false,
can_change_info: false,
can_invite_users: false,
can_pin_messages: false,
can_send_media_messages: false,
can_send_messages: false,
can_send_other_messages: false,
can_send_polls: false
}
});
req.end(function (res) {
if (res.error) throw new Error(res.error);
console.log(res.body);
});
const axios = require('axios').default;
const options = {
method: 'POST',
url: '{{baseUrl}}/setChatPermissions',
headers: {'content-type': 'application/json'},
data: {
chat_id: '',
permissions: {
can_add_web_page_previews: false,
can_change_info: false,
can_invite_users: false,
can_pin_messages: false,
can_send_media_messages: false,
can_send_messages: false,
can_send_other_messages: false,
can_send_polls: false
}
}
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const fetch = require('node-fetch');
const url = '{{baseUrl}}/setChatPermissions';
const options = {
method: 'POST',
headers: {'content-type': 'application/json'},
body: '{"chat_id":"","permissions":{"can_add_web_page_previews":false,"can_change_info":false,"can_invite_users":false,"can_pin_messages":false,"can_send_media_messages":false,"can_send_messages":false,"can_send_other_messages":false,"can_send_polls":false}}'
};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
#import
NSDictionary *headers = @{ @"content-type": @"application/json" };
NSDictionary *parameters = @{ @"chat_id": @"",
@"permissions": @{ @"can_add_web_page_previews": @NO, @"can_change_info": @NO, @"can_invite_users": @NO, @"can_pin_messages": @NO, @"can_send_media_messages": @NO, @"can_send_messages": @NO, @"can_send_other_messages": @NO, @"can_send_polls": @NO } };
NSData *postData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"{{baseUrl}}/setChatPermissions"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
[request setHTTPMethod:@"POST"];
[request setAllHTTPHeaderFields:headers];
[request setHTTPBody:postData];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSLog(@"%@", httpResponse);
}
}];
[dataTask resume];
open Cohttp_lwt_unix
open Cohttp
open Lwt
let uri = Uri.of_string "{{baseUrl}}/setChatPermissions" in
let headers = Header.add (Header.init ()) "content-type" "application/json" in
let body = Cohttp_lwt_body.of_string "{\n \"chat_id\": \"\",\n \"permissions\": {\n \"can_add_web_page_previews\": false,\n \"can_change_info\": false,\n \"can_invite_users\": false,\n \"can_pin_messages\": false,\n \"can_send_media_messages\": false,\n \"can_send_messages\": false,\n \"can_send_other_messages\": false,\n \"can_send_polls\": false\n }\n}" in
Client.call ~headers ~body `POST uri
>>= fun (res, body_stream) ->
(* Do stuff with the result *)
"{{baseUrl}}/setChatPermissions",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'chat_id' => '',
'permissions' => [
'can_add_web_page_previews' => null,
'can_change_info' => null,
'can_invite_users' => null,
'can_pin_messages' => null,
'can_send_media_messages' => null,
'can_send_messages' => null,
'can_send_other_messages' => null,
'can_send_polls' => null
]
]),
CURLOPT_HTTPHEADER => [
"content-type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
request('POST', '{{baseUrl}}/setChatPermissions', [
'body' => '{
"chat_id": "",
"permissions": {
"can_add_web_page_previews": false,
"can_change_info": false,
"can_invite_users": false,
"can_pin_messages": false,
"can_send_media_messages": false,
"can_send_messages": false,
"can_send_other_messages": false,
"can_send_polls": false
}
}',
'headers' => [
'content-type' => 'application/json',
],
]);
echo $response->getBody();
setUrl('{{baseUrl}}/setChatPermissions');
$request->setMethod(HTTP_METH_POST);
$request->setHeaders([
'content-type' => 'application/json'
]);
$request->setContentType('application/json');
$request->setBody(json_encode([
'chat_id' => '',
'permissions' => [
'can_add_web_page_previews' => null,
'can_change_info' => null,
'can_invite_users' => null,
'can_pin_messages' => null,
'can_send_media_messages' => null,
'can_send_messages' => null,
'can_send_other_messages' => null,
'can_send_polls' => null
]
]));
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
append(json_encode([
'chat_id' => '',
'permissions' => [
'can_add_web_page_previews' => null,
'can_change_info' => null,
'can_invite_users' => null,
'can_pin_messages' => null,
'can_send_media_messages' => null,
'can_send_messages' => null,
'can_send_other_messages' => null,
'can_send_polls' => null
]
]));
$request->setRequestUrl('{{baseUrl}}/setChatPermissions');
$request->setRequestMethod('POST');
$request->setBody($body);
$request->setHeaders([
'content-type' => 'application/json'
]);
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
$headers=@{}
$headers.Add("content-type", "application/json")
$response = Invoke-WebRequest -Uri '{{baseUrl}}/setChatPermissions' -Method POST -Headers $headers -ContentType 'application/json' -Body '{
"chat_id": "",
"permissions": {
"can_add_web_page_previews": false,
"can_change_info": false,
"can_invite_users": false,
"can_pin_messages": false,
"can_send_media_messages": false,
"can_send_messages": false,
"can_send_other_messages": false,
"can_send_polls": false
}
}'
$headers=@{}
$headers.Add("content-type", "application/json")
$response = Invoke-RestMethod -Uri '{{baseUrl}}/setChatPermissions' -Method POST -Headers $headers -ContentType 'application/json' -Body '{
"chat_id": "",
"permissions": {
"can_add_web_page_previews": false,
"can_change_info": false,
"can_invite_users": false,
"can_pin_messages": false,
"can_send_media_messages": false,
"can_send_messages": false,
"can_send_other_messages": false,
"can_send_polls": false
}
}'
import http.client
conn = http.client.HTTPSConnection("example.com")
payload = "{\n \"chat_id\": \"\",\n \"permissions\": {\n \"can_add_web_page_previews\": false,\n \"can_change_info\": false,\n \"can_invite_users\": false,\n \"can_pin_messages\": false,\n \"can_send_media_messages\": false,\n \"can_send_messages\": false,\n \"can_send_other_messages\": false,\n \"can_send_polls\": false\n }\n}"
headers = { 'content-type': "application/json" }
conn.request("POST", "/baseUrl/setChatPermissions", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
import requests
url = "{{baseUrl}}/setChatPermissions"
payload = {
"chat_id": "",
"permissions": {
"can_add_web_page_previews": False,
"can_change_info": False,
"can_invite_users": False,
"can_pin_messages": False,
"can_send_media_messages": False,
"can_send_messages": False,
"can_send_other_messages": False,
"can_send_polls": False
}
}
headers = {"content-type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
library(httr)
url <- "{{baseUrl}}/setChatPermissions"
payload <- "{\n \"chat_id\": \"\",\n \"permissions\": {\n \"can_add_web_page_previews\": false,\n \"can_change_info\": false,\n \"can_invite_users\": false,\n \"can_pin_messages\": false,\n \"can_send_media_messages\": false,\n \"can_send_messages\": false,\n \"can_send_other_messages\": false,\n \"can_send_polls\": false\n }\n}"
encode <- "json"
response <- VERB("POST", url, body = payload, content_type("application/json"), encode = encode)
content(response, "text")
require 'uri'
require 'net/http'
url = URI("{{baseUrl}}/setChatPermissions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["content-type"] = 'application/json'
request.body = "{\n \"chat_id\": \"\",\n \"permissions\": {\n \"can_add_web_page_previews\": false,\n \"can_change_info\": false,\n \"can_invite_users\": false,\n \"can_pin_messages\": false,\n \"can_send_media_messages\": false,\n \"can_send_messages\": false,\n \"can_send_other_messages\": false,\n \"can_send_polls\": false\n }\n}"
response = http.request(request)
puts response.read_body
require 'faraday'
conn = Faraday.new(
url: 'https://example.com',
headers: {'Content-Type' => 'application/json'}
)
response = conn.post('/baseUrl/setChatPermissions') do |req|
req.body = "{\n \"chat_id\": \"\",\n \"permissions\": {\n \"can_add_web_page_previews\": false,\n \"can_change_info\": false,\n \"can_invite_users\": false,\n \"can_pin_messages\": false,\n \"can_send_media_messages\": false,\n \"can_send_messages\": false,\n \"can_send_other_messages\": false,\n \"can_send_polls\": false\n }\n}"
end
puts response.status
puts response.body
use serde_json::json;
use reqwest;
#[tokio::main]
pub async fn main() {
let url = "{{baseUrl}}/setChatPermissions";
let payload = json!({
"chat_id": "",
"permissions": json!({
"can_add_web_page_previews": false,
"can_change_info": false,
"can_invite_users": false,
"can_pin_messages": false,
"can_send_media_messages": false,
"can_send_messages": false,
"can_send_other_messages": false,
"can_send_polls": false
})
});
let mut headers = reqwest::header::HeaderMap::new();
headers.insert("content-type", "application/json".parse().unwrap());
let client = reqwest::Client::new();
let response = client.post(url)
.headers(headers)
.json(&payload)
.send()
.await;
let results = response.unwrap()
.json::()
.await
.unwrap();
dbg!(results);
}
curl --request POST \
--url {{baseUrl}}/setChatPermissions \
--header 'content-type: application/json' \
--data '{
"chat_id": "",
"permissions": {
"can_add_web_page_previews": false,
"can_change_info": false,
"can_invite_users": false,
"can_pin_messages": false,
"can_send_media_messages": false,
"can_send_messages": false,
"can_send_other_messages": false,
"can_send_polls": false
}
}'
echo '{
"chat_id": "",
"permissions": {
"can_add_web_page_previews": false,
"can_change_info": false,
"can_invite_users": false,
"can_pin_messages": false,
"can_send_media_messages": false,
"can_send_messages": false,
"can_send_other_messages": false,
"can_send_polls": false
}
}' | \
http POST {{baseUrl}}/setChatPermissions \
content-type:application/json
wget --quiet \
--method POST \
--header 'content-type: application/json' \
--body-data '{\n "chat_id": "",\n "permissions": {\n "can_add_web_page_previews": false,\n "can_change_info": false,\n "can_invite_users": false,\n "can_pin_messages": false,\n "can_send_media_messages": false,\n "can_send_messages": false,\n "can_send_other_messages": false,\n "can_send_polls": false\n }\n}' \
--output-document \
- {{baseUrl}}/setChatPermissions
import Foundation
let headers = ["content-type": "application/json"]
let parameters = [
"chat_id": "",
"permissions": [
"can_add_web_page_previews": false,
"can_change_info": false,
"can_invite_users": false,
"can_pin_messages": false,
"can_send_media_messages": false,
"can_send_messages": false,
"can_send_other_messages": false,
"can_send_polls": false
]
] as [String : Any]
let postData = JSONSerialization.data(withJSONObject: parameters, options: [])
let request = NSMutableURLRequest(url: NSURL(string: "{{baseUrl}}/setChatPermissions")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error as Any)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
POST
Use this method to set the thumbnail of a sticker set. Animated thumbnails can be set for animated sticker sets only. Returns -True- on success.
{{baseUrl}}/setStickerSetThumb
BODY multipartForm
Examples
REQUEST
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(hnd, CURLOPT_URL, "{{baseUrl}}/setStickerSetThumb");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "content-type: multipart/form-data; boundary=---011000010111000001101001");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"name\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"thumb\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"user_id\"\r\n\r\n\r\n-----011000010111000001101001--\r\n");
CURLcode ret = curl_easy_perform(hnd);
(require '[clj-http.client :as client])
(client/post "{{baseUrl}}/setStickerSetThumb" {:multipart [{:name "name"
:content ""} {:name "thumb"
:content ""} {:name "user_id"
:content ""}]})
require "http/client"
url = "{{baseUrl}}/setStickerSetThumb"
headers = HTTP::Headers{
"content-type" => "multipart/form-data; boundary=---011000010111000001101001"
}
reqBody = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"name\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"thumb\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"user_id\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"
response = HTTP::Client.post url, headers: headers, body: reqBody
puts response.body
using System.Net.Http.Headers;
var client = new HttpClient();
var request = new HttpRequestMessage
{
Method = HttpMethod.Post,
RequestUri = new Uri("{{baseUrl}}/setStickerSetThumb"),
Content = new MultipartFormDataContent
{
new StringContent("")
{
Headers =
{
ContentDisposition = new ContentDispositionHeaderValue("form-data")
{
Name = "name",
}
}
},
new StringContent("")
{
Headers =
{
ContentDisposition = new ContentDispositionHeaderValue("form-data")
{
Name = "thumb",
}
}
},
new StringContent("")
{
Headers =
{
ContentDisposition = new ContentDispositionHeaderValue("form-data")
{
Name = "user_id",
}
}
},
},
};
using (var response = await client.SendAsync(request))
{
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
}
var client = new RestClient("{{baseUrl}}/setStickerSetThumb");
var request = new RestRequest("", Method.Post);
request.AddHeader("content-type", "multipart/form-data; boundary=---011000010111000001101001");
request.AddParameter("multipart/form-data; boundary=---011000010111000001101001", "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"name\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"thumb\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"user_id\"\r\n\r\n\r\n-----011000010111000001101001--\r\n", ParameterType.RequestBody);
var response = client.Execute(request);
package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "{{baseUrl}}/setStickerSetThumb"
payload := strings.NewReader("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"name\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"thumb\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"user_id\"\r\n\r\n\r\n-----011000010111000001101001--\r\n")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("content-type", "multipart/form-data; boundary=---011000010111000001101001")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
POST /baseUrl/setStickerSetThumb HTTP/1.1
Content-Type: multipart/form-data; boundary=---011000010111000001101001
Host: example.com
Content-Length: 277
-----011000010111000001101001
Content-Disposition: form-data; name="name"
-----011000010111000001101001
Content-Disposition: form-data; name="thumb"
-----011000010111000001101001
Content-Disposition: form-data; name="user_id"
-----011000010111000001101001--
AsyncHttpClient client = new DefaultAsyncHttpClient();
client.prepare("POST", "{{baseUrl}}/setStickerSetThumb")
.setHeader("content-type", "multipart/form-data; boundary=---011000010111000001101001")
.setBody("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"name\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"thumb\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"user_id\"\r\n\r\n\r\n-----011000010111000001101001--\r\n")
.execute()
.toCompletableFuture()
.thenAccept(System.out::println)
.join();
client.close();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("{{baseUrl}}/setStickerSetThumb"))
.header("content-type", "multipart/form-data; boundary=---011000010111000001101001")
.method("POST", HttpRequest.BodyPublishers.ofString("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"name\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"thumb\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"user_id\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"))
.build();
HttpResponse response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("multipart/form-data; boundary=---011000010111000001101001");
RequestBody body = RequestBody.create(mediaType, "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"name\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"thumb\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"user_id\"\r\n\r\n\r\n-----011000010111000001101001--\r\n");
Request request = new Request.Builder()
.url("{{baseUrl}}/setStickerSetThumb")
.post(body)
.addHeader("content-type", "multipart/form-data; boundary=---011000010111000001101001")
.build();
Response response = client.newCall(request).execute();
HttpResponse response = Unirest.post("{{baseUrl}}/setStickerSetThumb")
.header("content-type", "multipart/form-data; boundary=---011000010111000001101001")
.body("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"name\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"thumb\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"user_id\"\r\n\r\n\r\n-----011000010111000001101001--\r\n")
.asString();
const data = new FormData();
data.append('name', '');
data.append('thumb', '');
data.append('user_id', '');
const xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener('readystatechange', function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open('POST', '{{baseUrl}}/setStickerSetThumb');
xhr.send(data);
import axios from 'axios';
const form = new FormData();
form.append('name', '');
form.append('thumb', '');
form.append('user_id', '');
const options = {
method: 'POST',
url: '{{baseUrl}}/setStickerSetThumb',
headers: {'content-type': 'multipart/form-data; boundary=---011000010111000001101001'},
data: '[form]'
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const url = '{{baseUrl}}/setStickerSetThumb';
const form = new FormData();
form.append('name', '');
form.append('thumb', '');
form.append('user_id', '');
const options = {method: 'POST'};
options.body = form;
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
const form = new FormData();
form.append('name', '');
form.append('thumb', '');
form.append('user_id', '');
const settings = {
async: true,
crossDomain: true,
url: '{{baseUrl}}/setStickerSetThumb',
method: 'POST',
headers: {},
processData: false,
contentType: false,
mimeType: 'multipart/form-data',
data: form
};
$.ajax(settings).done(function (response) {
console.log(response);
});
val client = OkHttpClient()
val mediaType = MediaType.parse("multipart/form-data; boundary=---011000010111000001101001")
val body = RequestBody.create(mediaType, "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"name\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"thumb\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"user_id\"\r\n\r\n\r\n-----011000010111000001101001--\r\n")
val request = Request.Builder()
.url("{{baseUrl}}/setStickerSetThumb")
.post(body)
.addHeader("content-type", "multipart/form-data; boundary=---011000010111000001101001")
.build()
val response = client.newCall(request).execute()
const http = require('https');
const options = {
method: 'POST',
hostname: 'example.com',
port: null,
path: '/baseUrl/setStickerSetThumb',
headers: {
'content-type': 'multipart/form-data; boundary=---011000010111000001101001'
}
};
const req = http.request(options, function (res) {
const chunks = [];
res.on('data', function (chunk) {
chunks.push(chunk);
});
res.on('end', function () {
const body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.write('-----011000010111000001101001\r\nContent-Disposition: form-data; name="name"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name="thumb"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name="user_id"\r\n\r\n\r\n-----011000010111000001101001--\r\n');
req.end();
const request = require('request');
const options = {
method: 'POST',
url: '{{baseUrl}}/setStickerSetThumb',
headers: {'content-type': 'multipart/form-data; boundary=---011000010111000001101001'},
formData: {name: '', thumb: '', user_id: ''}
};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
const unirest = require('unirest');
const req = unirest('POST', '{{baseUrl}}/setStickerSetThumb');
req.headers({
'content-type': 'multipart/form-data; boundary=---011000010111000001101001'
});
req.multipart([]);
req.end(function (res) {
if (res.error) throw new Error(res.error);
console.log(res.body);
});
const axios = require('axios').default;
const options = {
method: 'POST',
url: '{{baseUrl}}/setStickerSetThumb',
headers: {'content-type': 'multipart/form-data; boundary=---011000010111000001101001'},
data: '-----011000010111000001101001\r\nContent-Disposition: form-data; name="name"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name="thumb"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name="user_id"\r\n\r\n\r\n-----011000010111000001101001--\r\n'
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const FormData = require('form-data');
const fetch = require('node-fetch');
const formData = new FormData();
formData.append('name', '');
formData.append('thumb', '');
formData.append('user_id', '');
const url = '{{baseUrl}}/setStickerSetThumb';
const options = {method: 'POST'};
options.body = formData;
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
#import
NSDictionary *headers = @{ @"content-type": @"multipart/form-data; boundary=---011000010111000001101001" };
NSArray *parameters = @[ @{ @"name": @"name", @"value": @"" },
@{ @"name": @"thumb", @"value": @"" },
@{ @"name": @"user_id", @"value": @"" } ];
NSString *boundary = @"---011000010111000001101001";
NSError *error;
NSMutableString *body = [NSMutableString string];
for (NSDictionary *param in parameters) {
[body appendFormat:@"--%@\r\n", boundary];
if (param[@"fileName"]) {
[body appendFormat:@"Content-Disposition:form-data; name=\"%@\"; filename=\"%@\"\r\n", param[@"name"], param[@"fileName"]];
[body appendFormat:@"Content-Type: %@\r\n\r\n", param[@"contentType"]];
[body appendFormat:@"%@", [NSString stringWithContentsOfFile:param[@"fileName"] encoding:NSUTF8StringEncoding error:&error]];
if (error) {
NSLog(@"%@", error);
}
} else {
[body appendFormat:@"Content-Disposition:form-data; name=\"%@\"\r\n\r\n", param[@"name"]];
[body appendFormat:@"%@", param[@"value"]];
}
}
[body appendFormat:@"\r\n--%@--\r\n", boundary];
NSData *postData = [body dataUsingEncoding:NSUTF8StringEncoding];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"{{baseUrl}}/setStickerSetThumb"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
[request setHTTPMethod:@"POST"];
[request setAllHTTPHeaderFields:headers];
[request setHTTPBody:postData];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSLog(@"%@", httpResponse);
}
}];
[dataTask resume];
open Cohttp_lwt_unix
open Cohttp
open Lwt
let uri = Uri.of_string "{{baseUrl}}/setStickerSetThumb" in
let headers = Header.add (Header.init ()) "content-type" "multipart/form-data; boundary=---011000010111000001101001" in
let body = Cohttp_lwt_body.of_string "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"name\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"thumb\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"user_id\"\r\n\r\n\r\n-----011000010111000001101001--\r\n" in
Client.call ~headers ~body `POST uri
>>= fun (res, body_stream) ->
(* Do stuff with the result *)
"{{baseUrl}}/setStickerSetThumb",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"name\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"thumb\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"user_id\"\r\n\r\n\r\n-----011000010111000001101001--\r\n",
CURLOPT_HTTPHEADER => [
"content-type: multipart/form-data; boundary=---011000010111000001101001"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
request('POST', '{{baseUrl}}/setStickerSetThumb', [
'headers' => [
'content-type' => 'multipart/form-data; boundary=---011000010111000001101001',
],
]);
echo $response->getBody();
setUrl('{{baseUrl}}/setStickerSetThumb');
$request->setMethod(HTTP_METH_POST);
$request->setHeaders([
'content-type' => 'multipart/form-data; boundary=---011000010111000001101001'
]);
$request->setBody('-----011000010111000001101001
Content-Disposition: form-data; name="name"
-----011000010111000001101001
Content-Disposition: form-data; name="thumb"
-----011000010111000001101001
Content-Disposition: form-data; name="user_id"
-----011000010111000001101001--
');
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
addForm(null, null);
$request->setRequestUrl('{{baseUrl}}/setStickerSetThumb');
$request->setRequestMethod('POST');
$request->setBody($body);
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
$headers=@{}
$headers.Add("content-type", "multipart/form-data; boundary=---011000010111000001101001")
$response = Invoke-WebRequest -Uri '{{baseUrl}}/setStickerSetThumb' -Method POST -Headers $headers -ContentType 'multipart/form-data; boundary=---011000010111000001101001' -Body '-----011000010111000001101001
Content-Disposition: form-data; name="name"
-----011000010111000001101001
Content-Disposition: form-data; name="thumb"
-----011000010111000001101001
Content-Disposition: form-data; name="user_id"
-----011000010111000001101001--
'
$headers=@{}
$headers.Add("content-type", "multipart/form-data; boundary=---011000010111000001101001")
$response = Invoke-RestMethod -Uri '{{baseUrl}}/setStickerSetThumb' -Method POST -Headers $headers -ContentType 'multipart/form-data; boundary=---011000010111000001101001' -Body '-----011000010111000001101001
Content-Disposition: form-data; name="name"
-----011000010111000001101001
Content-Disposition: form-data; name="thumb"
-----011000010111000001101001
Content-Disposition: form-data; name="user_id"
-----011000010111000001101001--
'
import http.client
conn = http.client.HTTPSConnection("example.com")
payload = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"name\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"thumb\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"user_id\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"
headers = { 'content-type': "multipart/form-data; boundary=---011000010111000001101001" }
conn.request("POST", "/baseUrl/setStickerSetThumb", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
import requests
url = "{{baseUrl}}/setStickerSetThumb"
payload = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"name\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"thumb\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"user_id\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"
headers = {"content-type": "multipart/form-data; boundary=---011000010111000001101001"}
response = requests.post(url, data=payload, headers=headers)
print(response.json())
library(httr)
url <- "{{baseUrl}}/setStickerSetThumb"
payload <- "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"name\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"thumb\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"user_id\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"
encode <- "multipart"
response <- VERB("POST", url, body = payload, content_type("multipart/form-data"), encode = encode)
content(response, "text")
require 'uri'
require 'net/http'
url = URI("{{baseUrl}}/setStickerSetThumb")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["content-type"] = 'multipart/form-data; boundary=---011000010111000001101001'
request.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"name\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"thumb\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"user_id\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"
response = http.request(request)
puts response.read_body
require 'faraday'
conn = Faraday.new(
url: 'https://example.com',
headers: {'Content-Type' => 'multipart/form-data; boundary=---011000010111000001101001'}
)
response = conn.post('/baseUrl/setStickerSetThumb') do |req|
req.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"name\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"thumb\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"user_id\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"
end
puts response.status
puts response.body
use reqwest;
#[tokio::main]
pub async fn main() {
let url = "{{baseUrl}}/setStickerSetThumb";
let form = reqwest::multipart::Form::new()
.text("name", "")
.text("thumb", "")
.text("user_id", "");
let mut headers = reqwest::header::HeaderMap::new();
let client = reqwest::Client::new();
let response = client.post(url)
.multipart(form)
.headers(headers)
.send()
.await;
let results = response.unwrap()
.json::()
.await
.unwrap();
dbg!(results);
}
curl --request POST \
--url {{baseUrl}}/setStickerSetThumb \
--header 'content-type: multipart/form-data' \
--form name= \
--form thumb= \
--form user_id=
echo '-----011000010111000001101001
Content-Disposition: form-data; name="name"
-----011000010111000001101001
Content-Disposition: form-data; name="thumb"
-----011000010111000001101001
Content-Disposition: form-data; name="user_id"
-----011000010111000001101001--
' | \
http POST {{baseUrl}}/setStickerSetThumb \
content-type:'multipart/form-data; boundary=---011000010111000001101001'
wget --quiet \
--method POST \
--header 'content-type: multipart/form-data; boundary=---011000010111000001101001' \
--body-data '-----011000010111000001101001\r\nContent-Disposition: form-data; name="name"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name="thumb"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name="user_id"\r\n\r\n\r\n-----011000010111000001101001--\r\n' \
--output-document \
- {{baseUrl}}/setStickerSetThumb
import Foundation
let headers = ["content-type": "multipart/form-data; boundary=---011000010111000001101001"]
let parameters = [
[
"name": "name",
"value": ""
],
[
"name": "thumb",
"value": ""
],
[
"name": "user_id",
"value": ""
]
]
let boundary = "---011000010111000001101001"
var body = ""
var error: NSError? = nil
for param in parameters {
let paramName = param["name"]!
body += "--\(boundary)\r\n"
body += "Content-Disposition:form-data; name=\"\(paramName)\""
if let filename = param["fileName"] {
let contentType = param["content-type"]!
let fileContent = String(contentsOfFile: filename, encoding: String.Encoding.utf8)
if (error != nil) {
print(error as Any)
}
body += "; filename=\"\(filename)\"\r\n"
body += "Content-Type: \(contentType)\r\n\r\n"
body += fileContent
} else if let paramValue = param["value"] {
body += "\r\n\r\n\(paramValue)"
}
}
let request = NSMutableURLRequest(url: NSURL(string: "{{baseUrl}}/setStickerSetThumb")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error as Any)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
POST
Use this method to stop a poll which was sent by the bot. On success, the stopped [Poll](https---core.telegram.org-bots-api-#poll) with the final results is returned.
{{baseUrl}}/stopPoll
BODY json
{
"chat_id": "",
"message_id": 0,
"reply_markup": {
"inline_keyboard": []
}
}
Examples
REQUEST
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(hnd, CURLOPT_URL, "{{baseUrl}}/stopPoll");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "content-type: application/json");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "{\n \"chat_id\": \"\",\n \"message_id\": 0,\n \"reply_markup\": {\n \"inline_keyboard\": []\n }\n}");
CURLcode ret = curl_easy_perform(hnd);
(require '[clj-http.client :as client])
(client/post "{{baseUrl}}/stopPoll" {:content-type :json
:form-params {:chat_id ""
:message_id 0
:reply_markup {:inline_keyboard []}}})
require "http/client"
url = "{{baseUrl}}/stopPoll"
headers = HTTP::Headers{
"content-type" => "application/json"
}
reqBody = "{\n \"chat_id\": \"\",\n \"message_id\": 0,\n \"reply_markup\": {\n \"inline_keyboard\": []\n }\n}"
response = HTTP::Client.post url, headers: headers, body: reqBody
puts response.body
using System.Net.Http.Headers;
var client = new HttpClient();
var request = new HttpRequestMessage
{
Method = HttpMethod.Post,
RequestUri = new Uri("{{baseUrl}}/stopPoll"),
Content = new StringContent("{\n \"chat_id\": \"\",\n \"message_id\": 0,\n \"reply_markup\": {\n \"inline_keyboard\": []\n }\n}")
{
Headers =
{
ContentType = new MediaTypeHeaderValue("application/json")
}
}
};
using (var response = await client.SendAsync(request))
{
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
}
var client = new RestClient("{{baseUrl}}/stopPoll");
var request = new RestRequest("", Method.Post);
request.AddHeader("content-type", "application/json");
request.AddParameter("application/json", "{\n \"chat_id\": \"\",\n \"message_id\": 0,\n \"reply_markup\": {\n \"inline_keyboard\": []\n }\n}", ParameterType.RequestBody);
var response = client.Execute(request);
package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "{{baseUrl}}/stopPoll"
payload := strings.NewReader("{\n \"chat_id\": \"\",\n \"message_id\": 0,\n \"reply_markup\": {\n \"inline_keyboard\": []\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("content-type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
POST /baseUrl/stopPoll HTTP/1.1
Content-Type: application/json
Host: example.com
Content-Length: 89
{
"chat_id": "",
"message_id": 0,
"reply_markup": {
"inline_keyboard": []
}
}
AsyncHttpClient client = new DefaultAsyncHttpClient();
client.prepare("POST", "{{baseUrl}}/stopPoll")
.setHeader("content-type", "application/json")
.setBody("{\n \"chat_id\": \"\",\n \"message_id\": 0,\n \"reply_markup\": {\n \"inline_keyboard\": []\n }\n}")
.execute()
.toCompletableFuture()
.thenAccept(System.out::println)
.join();
client.close();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("{{baseUrl}}/stopPoll"))
.header("content-type", "application/json")
.method("POST", HttpRequest.BodyPublishers.ofString("{\n \"chat_id\": \"\",\n \"message_id\": 0,\n \"reply_markup\": {\n \"inline_keyboard\": []\n }\n}"))
.build();
HttpResponse response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n \"chat_id\": \"\",\n \"message_id\": 0,\n \"reply_markup\": {\n \"inline_keyboard\": []\n }\n}");
Request request = new Request.Builder()
.url("{{baseUrl}}/stopPoll")
.post(body)
.addHeader("content-type", "application/json")
.build();
Response response = client.newCall(request).execute();
HttpResponse response = Unirest.post("{{baseUrl}}/stopPoll")
.header("content-type", "application/json")
.body("{\n \"chat_id\": \"\",\n \"message_id\": 0,\n \"reply_markup\": {\n \"inline_keyboard\": []\n }\n}")
.asString();
const data = JSON.stringify({
chat_id: '',
message_id: 0,
reply_markup: {
inline_keyboard: []
}
});
const xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener('readystatechange', function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open('POST', '{{baseUrl}}/stopPoll');
xhr.setRequestHeader('content-type', 'application/json');
xhr.send(data);
import axios from 'axios';
const options = {
method: 'POST',
url: '{{baseUrl}}/stopPoll',
headers: {'content-type': 'application/json'},
data: {chat_id: '', message_id: 0, reply_markup: {inline_keyboard: []}}
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const url = '{{baseUrl}}/stopPoll';
const options = {
method: 'POST',
headers: {'content-type': 'application/json'},
body: '{"chat_id":"","message_id":0,"reply_markup":{"inline_keyboard":[]}}'
};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
const settings = {
async: true,
crossDomain: true,
url: '{{baseUrl}}/stopPoll',
method: 'POST',
headers: {
'content-type': 'application/json'
},
processData: false,
data: '{\n "chat_id": "",\n "message_id": 0,\n "reply_markup": {\n "inline_keyboard": []\n }\n}'
};
$.ajax(settings).done(function (response) {
console.log(response);
});
val client = OkHttpClient()
val mediaType = MediaType.parse("application/json")
val body = RequestBody.create(mediaType, "{\n \"chat_id\": \"\",\n \"message_id\": 0,\n \"reply_markup\": {\n \"inline_keyboard\": []\n }\n}")
val request = Request.Builder()
.url("{{baseUrl}}/stopPoll")
.post(body)
.addHeader("content-type", "application/json")
.build()
val response = client.newCall(request).execute()
const http = require('https');
const options = {
method: 'POST',
hostname: 'example.com',
port: null,
path: '/baseUrl/stopPoll',
headers: {
'content-type': 'application/json'
}
};
const req = http.request(options, function (res) {
const chunks = [];
res.on('data', function (chunk) {
chunks.push(chunk);
});
res.on('end', function () {
const body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.write(JSON.stringify({chat_id: '', message_id: 0, reply_markup: {inline_keyboard: []}}));
req.end();
const request = require('request');
const options = {
method: 'POST',
url: '{{baseUrl}}/stopPoll',
headers: {'content-type': 'application/json'},
body: {chat_id: '', message_id: 0, reply_markup: {inline_keyboard: []}},
json: true
};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
const unirest = require('unirest');
const req = unirest('POST', '{{baseUrl}}/stopPoll');
req.headers({
'content-type': 'application/json'
});
req.type('json');
req.send({
chat_id: '',
message_id: 0,
reply_markup: {
inline_keyboard: []
}
});
req.end(function (res) {
if (res.error) throw new Error(res.error);
console.log(res.body);
});
const axios = require('axios').default;
const options = {
method: 'POST',
url: '{{baseUrl}}/stopPoll',
headers: {'content-type': 'application/json'},
data: {chat_id: '', message_id: 0, reply_markup: {inline_keyboard: []}}
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const fetch = require('node-fetch');
const url = '{{baseUrl}}/stopPoll';
const options = {
method: 'POST',
headers: {'content-type': 'application/json'},
body: '{"chat_id":"","message_id":0,"reply_markup":{"inline_keyboard":[]}}'
};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
#import
NSDictionary *headers = @{ @"content-type": @"application/json" };
NSDictionary *parameters = @{ @"chat_id": @"",
@"message_id": @0,
@"reply_markup": @{ @"inline_keyboard": @[ ] } };
NSData *postData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"{{baseUrl}}/stopPoll"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
[request setHTTPMethod:@"POST"];
[request setAllHTTPHeaderFields:headers];
[request setHTTPBody:postData];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSLog(@"%@", httpResponse);
}
}];
[dataTask resume];
open Cohttp_lwt_unix
open Cohttp
open Lwt
let uri = Uri.of_string "{{baseUrl}}/stopPoll" in
let headers = Header.add (Header.init ()) "content-type" "application/json" in
let body = Cohttp_lwt_body.of_string "{\n \"chat_id\": \"\",\n \"message_id\": 0,\n \"reply_markup\": {\n \"inline_keyboard\": []\n }\n}" in
Client.call ~headers ~body `POST uri
>>= fun (res, body_stream) ->
(* Do stuff with the result *)
"{{baseUrl}}/stopPoll",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'chat_id' => '',
'message_id' => 0,
'reply_markup' => [
'inline_keyboard' => [
]
]
]),
CURLOPT_HTTPHEADER => [
"content-type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
request('POST', '{{baseUrl}}/stopPoll', [
'body' => '{
"chat_id": "",
"message_id": 0,
"reply_markup": {
"inline_keyboard": []
}
}',
'headers' => [
'content-type' => 'application/json',
],
]);
echo $response->getBody();
setUrl('{{baseUrl}}/stopPoll');
$request->setMethod(HTTP_METH_POST);
$request->setHeaders([
'content-type' => 'application/json'
]);
$request->setContentType('application/json');
$request->setBody(json_encode([
'chat_id' => '',
'message_id' => 0,
'reply_markup' => [
'inline_keyboard' => [
]
]
]));
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
append(json_encode([
'chat_id' => '',
'message_id' => 0,
'reply_markup' => [
'inline_keyboard' => [
]
]
]));
$request->setRequestUrl('{{baseUrl}}/stopPoll');
$request->setRequestMethod('POST');
$request->setBody($body);
$request->setHeaders([
'content-type' => 'application/json'
]);
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
$headers=@{}
$headers.Add("content-type", "application/json")
$response = Invoke-WebRequest -Uri '{{baseUrl}}/stopPoll' -Method POST -Headers $headers -ContentType 'application/json' -Body '{
"chat_id": "",
"message_id": 0,
"reply_markup": {
"inline_keyboard": []
}
}'
$headers=@{}
$headers.Add("content-type", "application/json")
$response = Invoke-RestMethod -Uri '{{baseUrl}}/stopPoll' -Method POST -Headers $headers -ContentType 'application/json' -Body '{
"chat_id": "",
"message_id": 0,
"reply_markup": {
"inline_keyboard": []
}
}'
import http.client
conn = http.client.HTTPSConnection("example.com")
payload = "{\n \"chat_id\": \"\",\n \"message_id\": 0,\n \"reply_markup\": {\n \"inline_keyboard\": []\n }\n}"
headers = { 'content-type': "application/json" }
conn.request("POST", "/baseUrl/stopPoll", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
import requests
url = "{{baseUrl}}/stopPoll"
payload = {
"chat_id": "",
"message_id": 0,
"reply_markup": { "inline_keyboard": [] }
}
headers = {"content-type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
library(httr)
url <- "{{baseUrl}}/stopPoll"
payload <- "{\n \"chat_id\": \"\",\n \"message_id\": 0,\n \"reply_markup\": {\n \"inline_keyboard\": []\n }\n}"
encode <- "json"
response <- VERB("POST", url, body = payload, content_type("application/json"), encode = encode)
content(response, "text")
require 'uri'
require 'net/http'
url = URI("{{baseUrl}}/stopPoll")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["content-type"] = 'application/json'
request.body = "{\n \"chat_id\": \"\",\n \"message_id\": 0,\n \"reply_markup\": {\n \"inline_keyboard\": []\n }\n}"
response = http.request(request)
puts response.read_body
require 'faraday'
conn = Faraday.new(
url: 'https://example.com',
headers: {'Content-Type' => 'application/json'}
)
response = conn.post('/baseUrl/stopPoll') do |req|
req.body = "{\n \"chat_id\": \"\",\n \"message_id\": 0,\n \"reply_markup\": {\n \"inline_keyboard\": []\n }\n}"
end
puts response.status
puts response.body
use serde_json::json;
use reqwest;
#[tokio::main]
pub async fn main() {
let url = "{{baseUrl}}/stopPoll";
let payload = json!({
"chat_id": "",
"message_id": 0,
"reply_markup": json!({"inline_keyboard": ()})
});
let mut headers = reqwest::header::HeaderMap::new();
headers.insert("content-type", "application/json".parse().unwrap());
let client = reqwest::Client::new();
let response = client.post(url)
.headers(headers)
.json(&payload)
.send()
.await;
let results = response.unwrap()
.json::()
.await
.unwrap();
dbg!(results);
}
curl --request POST \
--url {{baseUrl}}/stopPoll \
--header 'content-type: application/json' \
--data '{
"chat_id": "",
"message_id": 0,
"reply_markup": {
"inline_keyboard": []
}
}'
echo '{
"chat_id": "",
"message_id": 0,
"reply_markup": {
"inline_keyboard": []
}
}' | \
http POST {{baseUrl}}/stopPoll \
content-type:application/json
wget --quiet \
--method POST \
--header 'content-type: application/json' \
--body-data '{\n "chat_id": "",\n "message_id": 0,\n "reply_markup": {\n "inline_keyboard": []\n }\n}' \
--output-document \
- {{baseUrl}}/stopPoll
import Foundation
let headers = ["content-type": "application/json"]
let parameters = [
"chat_id": "",
"message_id": 0,
"reply_markup": ["inline_keyboard": []]
] as [String : Any]
let postData = JSONSerialization.data(withJSONObject: parameters, options: [])
let request = NSMutableURLRequest(url: NSURL(string: "{{baseUrl}}/stopPoll")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error as Any)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
POST
Use this method to stop updating a live location message before -live-_period- expires. On success, if the message was sent by the bot, the sent [Message](https---core.telegram.org-bots-api-#message) is returned, otherwise -True- is returned.
{{baseUrl}}/stopMessageLiveLocation
BODY json
{
"chat_id": "",
"inline_message_id": "",
"message_id": 0,
"reply_markup": {
"inline_keyboard": []
}
}
Examples
REQUEST
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(hnd, CURLOPT_URL, "{{baseUrl}}/stopMessageLiveLocation");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "content-type: application/json");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "{\n \"chat_id\": \"\",\n \"inline_message_id\": \"\",\n \"message_id\": 0,\n \"reply_markup\": {\n \"inline_keyboard\": []\n }\n}");
CURLcode ret = curl_easy_perform(hnd);
(require '[clj-http.client :as client])
(client/post "{{baseUrl}}/stopMessageLiveLocation" {:content-type :json
:form-params {:chat_id ""
:inline_message_id ""
:message_id 0
:reply_markup {:inline_keyboard []}}})
require "http/client"
url = "{{baseUrl}}/stopMessageLiveLocation"
headers = HTTP::Headers{
"content-type" => "application/json"
}
reqBody = "{\n \"chat_id\": \"\",\n \"inline_message_id\": \"\",\n \"message_id\": 0,\n \"reply_markup\": {\n \"inline_keyboard\": []\n }\n}"
response = HTTP::Client.post url, headers: headers, body: reqBody
puts response.body
using System.Net.Http.Headers;
var client = new HttpClient();
var request = new HttpRequestMessage
{
Method = HttpMethod.Post,
RequestUri = new Uri("{{baseUrl}}/stopMessageLiveLocation"),
Content = new StringContent("{\n \"chat_id\": \"\",\n \"inline_message_id\": \"\",\n \"message_id\": 0,\n \"reply_markup\": {\n \"inline_keyboard\": []\n }\n}")
{
Headers =
{
ContentType = new MediaTypeHeaderValue("application/json")
}
}
};
using (var response = await client.SendAsync(request))
{
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
}
var client = new RestClient("{{baseUrl}}/stopMessageLiveLocation");
var request = new RestRequest("", Method.Post);
request.AddHeader("content-type", "application/json");
request.AddParameter("application/json", "{\n \"chat_id\": \"\",\n \"inline_message_id\": \"\",\n \"message_id\": 0,\n \"reply_markup\": {\n \"inline_keyboard\": []\n }\n}", ParameterType.RequestBody);
var response = client.Execute(request);
package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "{{baseUrl}}/stopMessageLiveLocation"
payload := strings.NewReader("{\n \"chat_id\": \"\",\n \"inline_message_id\": \"\",\n \"message_id\": 0,\n \"reply_markup\": {\n \"inline_keyboard\": []\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("content-type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
POST /baseUrl/stopMessageLiveLocation HTTP/1.1
Content-Type: application/json
Host: example.com
Content-Length: 116
{
"chat_id": "",
"inline_message_id": "",
"message_id": 0,
"reply_markup": {
"inline_keyboard": []
}
}
AsyncHttpClient client = new DefaultAsyncHttpClient();
client.prepare("POST", "{{baseUrl}}/stopMessageLiveLocation")
.setHeader("content-type", "application/json")
.setBody("{\n \"chat_id\": \"\",\n \"inline_message_id\": \"\",\n \"message_id\": 0,\n \"reply_markup\": {\n \"inline_keyboard\": []\n }\n}")
.execute()
.toCompletableFuture()
.thenAccept(System.out::println)
.join();
client.close();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("{{baseUrl}}/stopMessageLiveLocation"))
.header("content-type", "application/json")
.method("POST", HttpRequest.BodyPublishers.ofString("{\n \"chat_id\": \"\",\n \"inline_message_id\": \"\",\n \"message_id\": 0,\n \"reply_markup\": {\n \"inline_keyboard\": []\n }\n}"))
.build();
HttpResponse response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n \"chat_id\": \"\",\n \"inline_message_id\": \"\",\n \"message_id\": 0,\n \"reply_markup\": {\n \"inline_keyboard\": []\n }\n}");
Request request = new Request.Builder()
.url("{{baseUrl}}/stopMessageLiveLocation")
.post(body)
.addHeader("content-type", "application/json")
.build();
Response response = client.newCall(request).execute();
HttpResponse response = Unirest.post("{{baseUrl}}/stopMessageLiveLocation")
.header("content-type", "application/json")
.body("{\n \"chat_id\": \"\",\n \"inline_message_id\": \"\",\n \"message_id\": 0,\n \"reply_markup\": {\n \"inline_keyboard\": []\n }\n}")
.asString();
const data = JSON.stringify({
chat_id: '',
inline_message_id: '',
message_id: 0,
reply_markup: {
inline_keyboard: []
}
});
const xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener('readystatechange', function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open('POST', '{{baseUrl}}/stopMessageLiveLocation');
xhr.setRequestHeader('content-type', 'application/json');
xhr.send(data);
import axios from 'axios';
const options = {
method: 'POST',
url: '{{baseUrl}}/stopMessageLiveLocation',
headers: {'content-type': 'application/json'},
data: {
chat_id: '',
inline_message_id: '',
message_id: 0,
reply_markup: {inline_keyboard: []}
}
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const url = '{{baseUrl}}/stopMessageLiveLocation';
const options = {
method: 'POST',
headers: {'content-type': 'application/json'},
body: '{"chat_id":"","inline_message_id":"","message_id":0,"reply_markup":{"inline_keyboard":[]}}'
};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
const settings = {
async: true,
crossDomain: true,
url: '{{baseUrl}}/stopMessageLiveLocation',
method: 'POST',
headers: {
'content-type': 'application/json'
},
processData: false,
data: '{\n "chat_id": "",\n "inline_message_id": "",\n "message_id": 0,\n "reply_markup": {\n "inline_keyboard": []\n }\n}'
};
$.ajax(settings).done(function (response) {
console.log(response);
});
val client = OkHttpClient()
val mediaType = MediaType.parse("application/json")
val body = RequestBody.create(mediaType, "{\n \"chat_id\": \"\",\n \"inline_message_id\": \"\",\n \"message_id\": 0,\n \"reply_markup\": {\n \"inline_keyboard\": []\n }\n}")
val request = Request.Builder()
.url("{{baseUrl}}/stopMessageLiveLocation")
.post(body)
.addHeader("content-type", "application/json")
.build()
val response = client.newCall(request).execute()
const http = require('https');
const options = {
method: 'POST',
hostname: 'example.com',
port: null,
path: '/baseUrl/stopMessageLiveLocation',
headers: {
'content-type': 'application/json'
}
};
const req = http.request(options, function (res) {
const chunks = [];
res.on('data', function (chunk) {
chunks.push(chunk);
});
res.on('end', function () {
const body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.write(JSON.stringify({
chat_id: '',
inline_message_id: '',
message_id: 0,
reply_markup: {inline_keyboard: []}
}));
req.end();
const request = require('request');
const options = {
method: 'POST',
url: '{{baseUrl}}/stopMessageLiveLocation',
headers: {'content-type': 'application/json'},
body: {
chat_id: '',
inline_message_id: '',
message_id: 0,
reply_markup: {inline_keyboard: []}
},
json: true
};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
const unirest = require('unirest');
const req = unirest('POST', '{{baseUrl}}/stopMessageLiveLocation');
req.headers({
'content-type': 'application/json'
});
req.type('json');
req.send({
chat_id: '',
inline_message_id: '',
message_id: 0,
reply_markup: {
inline_keyboard: []
}
});
req.end(function (res) {
if (res.error) throw new Error(res.error);
console.log(res.body);
});
const axios = require('axios').default;
const options = {
method: 'POST',
url: '{{baseUrl}}/stopMessageLiveLocation',
headers: {'content-type': 'application/json'},
data: {
chat_id: '',
inline_message_id: '',
message_id: 0,
reply_markup: {inline_keyboard: []}
}
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const fetch = require('node-fetch');
const url = '{{baseUrl}}/stopMessageLiveLocation';
const options = {
method: 'POST',
headers: {'content-type': 'application/json'},
body: '{"chat_id":"","inline_message_id":"","message_id":0,"reply_markup":{"inline_keyboard":[]}}'
};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
#import
NSDictionary *headers = @{ @"content-type": @"application/json" };
NSDictionary *parameters = @{ @"chat_id": @"",
@"inline_message_id": @"",
@"message_id": @0,
@"reply_markup": @{ @"inline_keyboard": @[ ] } };
NSData *postData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"{{baseUrl}}/stopMessageLiveLocation"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
[request setHTTPMethod:@"POST"];
[request setAllHTTPHeaderFields:headers];
[request setHTTPBody:postData];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSLog(@"%@", httpResponse);
}
}];
[dataTask resume];
open Cohttp_lwt_unix
open Cohttp
open Lwt
let uri = Uri.of_string "{{baseUrl}}/stopMessageLiveLocation" in
let headers = Header.add (Header.init ()) "content-type" "application/json" in
let body = Cohttp_lwt_body.of_string "{\n \"chat_id\": \"\",\n \"inline_message_id\": \"\",\n \"message_id\": 0,\n \"reply_markup\": {\n \"inline_keyboard\": []\n }\n}" in
Client.call ~headers ~body `POST uri
>>= fun (res, body_stream) ->
(* Do stuff with the result *)
"{{baseUrl}}/stopMessageLiveLocation",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'chat_id' => '',
'inline_message_id' => '',
'message_id' => 0,
'reply_markup' => [
'inline_keyboard' => [
]
]
]),
CURLOPT_HTTPHEADER => [
"content-type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
request('POST', '{{baseUrl}}/stopMessageLiveLocation', [
'body' => '{
"chat_id": "",
"inline_message_id": "",
"message_id": 0,
"reply_markup": {
"inline_keyboard": []
}
}',
'headers' => [
'content-type' => 'application/json',
],
]);
echo $response->getBody();
setUrl('{{baseUrl}}/stopMessageLiveLocation');
$request->setMethod(HTTP_METH_POST);
$request->setHeaders([
'content-type' => 'application/json'
]);
$request->setContentType('application/json');
$request->setBody(json_encode([
'chat_id' => '',
'inline_message_id' => '',
'message_id' => 0,
'reply_markup' => [
'inline_keyboard' => [
]
]
]));
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
append(json_encode([
'chat_id' => '',
'inline_message_id' => '',
'message_id' => 0,
'reply_markup' => [
'inline_keyboard' => [
]
]
]));
$request->setRequestUrl('{{baseUrl}}/stopMessageLiveLocation');
$request->setRequestMethod('POST');
$request->setBody($body);
$request->setHeaders([
'content-type' => 'application/json'
]);
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
$headers=@{}
$headers.Add("content-type", "application/json")
$response = Invoke-WebRequest -Uri '{{baseUrl}}/stopMessageLiveLocation' -Method POST -Headers $headers -ContentType 'application/json' -Body '{
"chat_id": "",
"inline_message_id": "",
"message_id": 0,
"reply_markup": {
"inline_keyboard": []
}
}'
$headers=@{}
$headers.Add("content-type", "application/json")
$response = Invoke-RestMethod -Uri '{{baseUrl}}/stopMessageLiveLocation' -Method POST -Headers $headers -ContentType 'application/json' -Body '{
"chat_id": "",
"inline_message_id": "",
"message_id": 0,
"reply_markup": {
"inline_keyboard": []
}
}'
import http.client
conn = http.client.HTTPSConnection("example.com")
payload = "{\n \"chat_id\": \"\",\n \"inline_message_id\": \"\",\n \"message_id\": 0,\n \"reply_markup\": {\n \"inline_keyboard\": []\n }\n}"
headers = { 'content-type': "application/json" }
conn.request("POST", "/baseUrl/stopMessageLiveLocation", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
import requests
url = "{{baseUrl}}/stopMessageLiveLocation"
payload = {
"chat_id": "",
"inline_message_id": "",
"message_id": 0,
"reply_markup": { "inline_keyboard": [] }
}
headers = {"content-type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
library(httr)
url <- "{{baseUrl}}/stopMessageLiveLocation"
payload <- "{\n \"chat_id\": \"\",\n \"inline_message_id\": \"\",\n \"message_id\": 0,\n \"reply_markup\": {\n \"inline_keyboard\": []\n }\n}"
encode <- "json"
response <- VERB("POST", url, body = payload, content_type("application/json"), encode = encode)
content(response, "text")
require 'uri'
require 'net/http'
url = URI("{{baseUrl}}/stopMessageLiveLocation")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["content-type"] = 'application/json'
request.body = "{\n \"chat_id\": \"\",\n \"inline_message_id\": \"\",\n \"message_id\": 0,\n \"reply_markup\": {\n \"inline_keyboard\": []\n }\n}"
response = http.request(request)
puts response.read_body
require 'faraday'
conn = Faraday.new(
url: 'https://example.com',
headers: {'Content-Type' => 'application/json'}
)
response = conn.post('/baseUrl/stopMessageLiveLocation') do |req|
req.body = "{\n \"chat_id\": \"\",\n \"inline_message_id\": \"\",\n \"message_id\": 0,\n \"reply_markup\": {\n \"inline_keyboard\": []\n }\n}"
end
puts response.status
puts response.body
use serde_json::json;
use reqwest;
#[tokio::main]
pub async fn main() {
let url = "{{baseUrl}}/stopMessageLiveLocation";
let payload = json!({
"chat_id": "",
"inline_message_id": "",
"message_id": 0,
"reply_markup": json!({"inline_keyboard": ()})
});
let mut headers = reqwest::header::HeaderMap::new();
headers.insert("content-type", "application/json".parse().unwrap());
let client = reqwest::Client::new();
let response = client.post(url)
.headers(headers)
.json(&payload)
.send()
.await;
let results = response.unwrap()
.json::()
.await
.unwrap();
dbg!(results);
}
curl --request POST \
--url {{baseUrl}}/stopMessageLiveLocation \
--header 'content-type: application/json' \
--data '{
"chat_id": "",
"inline_message_id": "",
"message_id": 0,
"reply_markup": {
"inline_keyboard": []
}
}'
echo '{
"chat_id": "",
"inline_message_id": "",
"message_id": 0,
"reply_markup": {
"inline_keyboard": []
}
}' | \
http POST {{baseUrl}}/stopMessageLiveLocation \
content-type:application/json
wget --quiet \
--method POST \
--header 'content-type: application/json' \
--body-data '{\n "chat_id": "",\n "inline_message_id": "",\n "message_id": 0,\n "reply_markup": {\n "inline_keyboard": []\n }\n}' \
--output-document \
- {{baseUrl}}/stopMessageLiveLocation
import Foundation
let headers = ["content-type": "application/json"]
let parameters = [
"chat_id": "",
"inline_message_id": "",
"message_id": 0,
"reply_markup": ["inline_keyboard": []]
] as [String : Any]
let postData = JSONSerialization.data(withJSONObject: parameters, options: [])
let request = NSMutableURLRequest(url: NSURL(string: "{{baseUrl}}/stopMessageLiveLocation")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error as Any)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
POST
Use this method to upload a .PNG file with a sticker for later use in -createNewStickerSet- and -addStickerToSet- methods (can be used multiple times). Returns the uploaded [File](https---core.telegram.org-bots-api-#file) on success.
{{baseUrl}}/uploadStickerFile
BODY multipartForm
Examples
REQUEST
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(hnd, CURLOPT_URL, "{{baseUrl}}/uploadStickerFile");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "content-type: multipart/form-data; boundary=---011000010111000001101001");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"png_sticker\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"user_id\"\r\n\r\n\r\n-----011000010111000001101001--\r\n");
CURLcode ret = curl_easy_perform(hnd);
(require '[clj-http.client :as client])
(client/post "{{baseUrl}}/uploadStickerFile" {:multipart [{:name "png_sticker"
:content ""} {:name "user_id"
:content ""}]})
require "http/client"
url = "{{baseUrl}}/uploadStickerFile"
headers = HTTP::Headers{
"content-type" => "multipart/form-data; boundary=---011000010111000001101001"
}
reqBody = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"png_sticker\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"user_id\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"
response = HTTP::Client.post url, headers: headers, body: reqBody
puts response.body
using System.Net.Http.Headers;
var client = new HttpClient();
var request = new HttpRequestMessage
{
Method = HttpMethod.Post,
RequestUri = new Uri("{{baseUrl}}/uploadStickerFile"),
Content = new MultipartFormDataContent
{
new StringContent("")
{
Headers =
{
ContentDisposition = new ContentDispositionHeaderValue("form-data")
{
Name = "png_sticker",
}
}
},
new StringContent("")
{
Headers =
{
ContentDisposition = new ContentDispositionHeaderValue("form-data")
{
Name = "user_id",
}
}
},
},
};
using (var response = await client.SendAsync(request))
{
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
}
var client = new RestClient("{{baseUrl}}/uploadStickerFile");
var request = new RestRequest("", Method.Post);
request.AddHeader("content-type", "multipart/form-data; boundary=---011000010111000001101001");
request.AddParameter("multipart/form-data; boundary=---011000010111000001101001", "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"png_sticker\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"user_id\"\r\n\r\n\r\n-----011000010111000001101001--\r\n", ParameterType.RequestBody);
var response = client.Execute(request);
package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "{{baseUrl}}/uploadStickerFile"
payload := strings.NewReader("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"png_sticker\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"user_id\"\r\n\r\n\r\n-----011000010111000001101001--\r\n")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("content-type", "multipart/form-data; boundary=---011000010111000001101001")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
POST /baseUrl/uploadStickerFile HTTP/1.1
Content-Type: multipart/form-data; boundary=---011000010111000001101001
Host: example.com
Content-Length: 203
-----011000010111000001101001
Content-Disposition: form-data; name="png_sticker"
-----011000010111000001101001
Content-Disposition: form-data; name="user_id"
-----011000010111000001101001--
AsyncHttpClient client = new DefaultAsyncHttpClient();
client.prepare("POST", "{{baseUrl}}/uploadStickerFile")
.setHeader("content-type", "multipart/form-data; boundary=---011000010111000001101001")
.setBody("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"png_sticker\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"user_id\"\r\n\r\n\r\n-----011000010111000001101001--\r\n")
.execute()
.toCompletableFuture()
.thenAccept(System.out::println)
.join();
client.close();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("{{baseUrl}}/uploadStickerFile"))
.header("content-type", "multipart/form-data; boundary=---011000010111000001101001")
.method("POST", HttpRequest.BodyPublishers.ofString("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"png_sticker\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"user_id\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"))
.build();
HttpResponse response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("multipart/form-data; boundary=---011000010111000001101001");
RequestBody body = RequestBody.create(mediaType, "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"png_sticker\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"user_id\"\r\n\r\n\r\n-----011000010111000001101001--\r\n");
Request request = new Request.Builder()
.url("{{baseUrl}}/uploadStickerFile")
.post(body)
.addHeader("content-type", "multipart/form-data; boundary=---011000010111000001101001")
.build();
Response response = client.newCall(request).execute();
HttpResponse response = Unirest.post("{{baseUrl}}/uploadStickerFile")
.header("content-type", "multipart/form-data; boundary=---011000010111000001101001")
.body("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"png_sticker\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"user_id\"\r\n\r\n\r\n-----011000010111000001101001--\r\n")
.asString();
const data = new FormData();
data.append('png_sticker', '');
data.append('user_id', '');
const xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener('readystatechange', function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open('POST', '{{baseUrl}}/uploadStickerFile');
xhr.send(data);
import axios from 'axios';
const form = new FormData();
form.append('png_sticker', '');
form.append('user_id', '');
const options = {
method: 'POST',
url: '{{baseUrl}}/uploadStickerFile',
headers: {'content-type': 'multipart/form-data; boundary=---011000010111000001101001'},
data: '[form]'
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const url = '{{baseUrl}}/uploadStickerFile';
const form = new FormData();
form.append('png_sticker', '');
form.append('user_id', '');
const options = {method: 'POST'};
options.body = form;
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
const form = new FormData();
form.append('png_sticker', '');
form.append('user_id', '');
const settings = {
async: true,
crossDomain: true,
url: '{{baseUrl}}/uploadStickerFile',
method: 'POST',
headers: {},
processData: false,
contentType: false,
mimeType: 'multipart/form-data',
data: form
};
$.ajax(settings).done(function (response) {
console.log(response);
});
val client = OkHttpClient()
val mediaType = MediaType.parse("multipart/form-data; boundary=---011000010111000001101001")
val body = RequestBody.create(mediaType, "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"png_sticker\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"user_id\"\r\n\r\n\r\n-----011000010111000001101001--\r\n")
val request = Request.Builder()
.url("{{baseUrl}}/uploadStickerFile")
.post(body)
.addHeader("content-type", "multipart/form-data; boundary=---011000010111000001101001")
.build()
val response = client.newCall(request).execute()
const http = require('https');
const options = {
method: 'POST',
hostname: 'example.com',
port: null,
path: '/baseUrl/uploadStickerFile',
headers: {
'content-type': 'multipart/form-data; boundary=---011000010111000001101001'
}
};
const req = http.request(options, function (res) {
const chunks = [];
res.on('data', function (chunk) {
chunks.push(chunk);
});
res.on('end', function () {
const body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.write('-----011000010111000001101001\r\nContent-Disposition: form-data; name="png_sticker"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name="user_id"\r\n\r\n\r\n-----011000010111000001101001--\r\n');
req.end();
const request = require('request');
const options = {
method: 'POST',
url: '{{baseUrl}}/uploadStickerFile',
headers: {'content-type': 'multipart/form-data; boundary=---011000010111000001101001'},
formData: {png_sticker: '', user_id: ''}
};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
const unirest = require('unirest');
const req = unirest('POST', '{{baseUrl}}/uploadStickerFile');
req.headers({
'content-type': 'multipart/form-data; boundary=---011000010111000001101001'
});
req.multipart([]);
req.end(function (res) {
if (res.error) throw new Error(res.error);
console.log(res.body);
});
const axios = require('axios').default;
const options = {
method: 'POST',
url: '{{baseUrl}}/uploadStickerFile',
headers: {'content-type': 'multipart/form-data; boundary=---011000010111000001101001'},
data: '-----011000010111000001101001\r\nContent-Disposition: form-data; name="png_sticker"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name="user_id"\r\n\r\n\r\n-----011000010111000001101001--\r\n'
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const FormData = require('form-data');
const fetch = require('node-fetch');
const formData = new FormData();
formData.append('png_sticker', '');
formData.append('user_id', '');
const url = '{{baseUrl}}/uploadStickerFile';
const options = {method: 'POST'};
options.body = formData;
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
#import
NSDictionary *headers = @{ @"content-type": @"multipart/form-data; boundary=---011000010111000001101001" };
NSArray *parameters = @[ @{ @"name": @"png_sticker", @"value": @"" },
@{ @"name": @"user_id", @"value": @"" } ];
NSString *boundary = @"---011000010111000001101001";
NSError *error;
NSMutableString *body = [NSMutableString string];
for (NSDictionary *param in parameters) {
[body appendFormat:@"--%@\r\n", boundary];
if (param[@"fileName"]) {
[body appendFormat:@"Content-Disposition:form-data; name=\"%@\"; filename=\"%@\"\r\n", param[@"name"], param[@"fileName"]];
[body appendFormat:@"Content-Type: %@\r\n\r\n", param[@"contentType"]];
[body appendFormat:@"%@", [NSString stringWithContentsOfFile:param[@"fileName"] encoding:NSUTF8StringEncoding error:&error]];
if (error) {
NSLog(@"%@", error);
}
} else {
[body appendFormat:@"Content-Disposition:form-data; name=\"%@\"\r\n\r\n", param[@"name"]];
[body appendFormat:@"%@", param[@"value"]];
}
}
[body appendFormat:@"\r\n--%@--\r\n", boundary];
NSData *postData = [body dataUsingEncoding:NSUTF8StringEncoding];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"{{baseUrl}}/uploadStickerFile"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
[request setHTTPMethod:@"POST"];
[request setAllHTTPHeaderFields:headers];
[request setHTTPBody:postData];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSLog(@"%@", httpResponse);
}
}];
[dataTask resume];
open Cohttp_lwt_unix
open Cohttp
open Lwt
let uri = Uri.of_string "{{baseUrl}}/uploadStickerFile" in
let headers = Header.add (Header.init ()) "content-type" "multipart/form-data; boundary=---011000010111000001101001" in
let body = Cohttp_lwt_body.of_string "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"png_sticker\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"user_id\"\r\n\r\n\r\n-----011000010111000001101001--\r\n" in
Client.call ~headers ~body `POST uri
>>= fun (res, body_stream) ->
(* Do stuff with the result *)
"{{baseUrl}}/uploadStickerFile",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"png_sticker\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"user_id\"\r\n\r\n\r\n-----011000010111000001101001--\r\n",
CURLOPT_HTTPHEADER => [
"content-type: multipart/form-data; boundary=---011000010111000001101001"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
request('POST', '{{baseUrl}}/uploadStickerFile', [
'headers' => [
'content-type' => 'multipart/form-data; boundary=---011000010111000001101001',
],
]);
echo $response->getBody();
setUrl('{{baseUrl}}/uploadStickerFile');
$request->setMethod(HTTP_METH_POST);
$request->setHeaders([
'content-type' => 'multipart/form-data; boundary=---011000010111000001101001'
]);
$request->setBody('-----011000010111000001101001
Content-Disposition: form-data; name="png_sticker"
-----011000010111000001101001
Content-Disposition: form-data; name="user_id"
-----011000010111000001101001--
');
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
addForm(null, null);
$request->setRequestUrl('{{baseUrl}}/uploadStickerFile');
$request->setRequestMethod('POST');
$request->setBody($body);
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
$headers=@{}
$headers.Add("content-type", "multipart/form-data; boundary=---011000010111000001101001")
$response = Invoke-WebRequest -Uri '{{baseUrl}}/uploadStickerFile' -Method POST -Headers $headers -ContentType 'multipart/form-data; boundary=---011000010111000001101001' -Body '-----011000010111000001101001
Content-Disposition: form-data; name="png_sticker"
-----011000010111000001101001
Content-Disposition: form-data; name="user_id"
-----011000010111000001101001--
'
$headers=@{}
$headers.Add("content-type", "multipart/form-data; boundary=---011000010111000001101001")
$response = Invoke-RestMethod -Uri '{{baseUrl}}/uploadStickerFile' -Method POST -Headers $headers -ContentType 'multipart/form-data; boundary=---011000010111000001101001' -Body '-----011000010111000001101001
Content-Disposition: form-data; name="png_sticker"
-----011000010111000001101001
Content-Disposition: form-data; name="user_id"
-----011000010111000001101001--
'
import http.client
conn = http.client.HTTPSConnection("example.com")
payload = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"png_sticker\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"user_id\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"
headers = { 'content-type': "multipart/form-data; boundary=---011000010111000001101001" }
conn.request("POST", "/baseUrl/uploadStickerFile", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
import requests
url = "{{baseUrl}}/uploadStickerFile"
payload = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"png_sticker\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"user_id\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"
headers = {"content-type": "multipart/form-data; boundary=---011000010111000001101001"}
response = requests.post(url, data=payload, headers=headers)
print(response.json())
library(httr)
url <- "{{baseUrl}}/uploadStickerFile"
payload <- "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"png_sticker\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"user_id\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"
encode <- "multipart"
response <- VERB("POST", url, body = payload, content_type("multipart/form-data"), encode = encode)
content(response, "text")
require 'uri'
require 'net/http'
url = URI("{{baseUrl}}/uploadStickerFile")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["content-type"] = 'multipart/form-data; boundary=---011000010111000001101001'
request.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"png_sticker\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"user_id\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"
response = http.request(request)
puts response.read_body
require 'faraday'
conn = Faraday.new(
url: 'https://example.com',
headers: {'Content-Type' => 'multipart/form-data; boundary=---011000010111000001101001'}
)
response = conn.post('/baseUrl/uploadStickerFile') do |req|
req.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"png_sticker\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"user_id\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"
end
puts response.status
puts response.body
use reqwest;
#[tokio::main]
pub async fn main() {
let url = "{{baseUrl}}/uploadStickerFile";
let form = reqwest::multipart::Form::new()
.text("png_sticker", "")
.text("user_id", "");
let mut headers = reqwest::header::HeaderMap::new();
let client = reqwest::Client::new();
let response = client.post(url)
.multipart(form)
.headers(headers)
.send()
.await;
let results = response.unwrap()
.json::()
.await
.unwrap();
dbg!(results);
}
curl --request POST \
--url {{baseUrl}}/uploadStickerFile \
--header 'content-type: multipart/form-data' \
--form png_sticker= \
--form user_id=
echo '-----011000010111000001101001
Content-Disposition: form-data; name="png_sticker"
-----011000010111000001101001
Content-Disposition: form-data; name="user_id"
-----011000010111000001101001--
' | \
http POST {{baseUrl}}/uploadStickerFile \
content-type:'multipart/form-data; boundary=---011000010111000001101001'
wget --quiet \
--method POST \
--header 'content-type: multipart/form-data; boundary=---011000010111000001101001' \
--body-data '-----011000010111000001101001\r\nContent-Disposition: form-data; name="png_sticker"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name="user_id"\r\n\r\n\r\n-----011000010111000001101001--\r\n' \
--output-document \
- {{baseUrl}}/uploadStickerFile
import Foundation
let headers = ["content-type": "multipart/form-data; boundary=---011000010111000001101001"]
let parameters = [
[
"name": "png_sticker",
"value": ""
],
[
"name": "user_id",
"value": ""
]
]
let boundary = "---011000010111000001101001"
var body = ""
var error: NSError? = nil
for param in parameters {
let paramName = param["name"]!
body += "--\(boundary)\r\n"
body += "Content-Disposition:form-data; name=\"\(paramName)\""
if let filename = param["fileName"] {
let contentType = param["content-type"]!
let fileContent = String(contentsOfFile: filename, encoding: String.Encoding.utf8)
if (error != nil) {
print(error as Any)
}
body += "; filename=\"\(filename)\"\r\n"
body += "Content-Type: \(contentType)\r\n\r\n"
body += fileContent
} else if let paramValue = param["value"] {
body += "\r\n\r\n\(paramValue)"
}
}
let request = NSMutableURLRequest(url: NSURL(string: "{{baseUrl}}/uploadStickerFile")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error as Any)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()