Skip to content

SetGroupPicture#

Postman Test

The method sets a group avatar.

The method uses limits on the request rate per second.

Request#

To set a group chat avatar, you need to execute a request at:

POST
{{apiUrl}}/waInstance{{idInstance}}/setGroupPicture/{{apiTokenInstance}}

To get the apiUrl, idInstance and apiTokenInstance request parameters, refer to the Before you start section.

Request parameters#

Parameter Type Required Description
file file Yes File being sent in *.jpg format
chatId string Yes Group chat identifier

Response#

Response fields#

Field Type Description
setGroupPicture boolean Flag with the result of setting the group avatar
urlAvatar string Link to the image that was set
reason string The reason why the avatar was not set

Response body example#

{
    "reason": "",
    "urlAvatar": "https://4100.api.green-api.com/download/4100/dbUwUqCIPQgiOI.jpg",
    "setGroupPicture": true
}

SetGroupPicture errors#

For the list of errors common to all methods, see the Common errors section

HTTP code Error identifier Description
200 {
"reason": "Timed Out",
"urlAvatar": "",
"setGroupPicture": false
}
Incorrect data type of the chatId field

or an incorrect chatId
400 Bad Request
Validation failed
Validation error
400 File is empty Empty file
400 Unsupported media type Unsupported file format

Code examples#

import requests

url = "{{apiUrl}}/waInstance{{idInstance}}/setGroupPicture/{{apiTokenInstance}}"

payload = {(
    "chatId": "-10000000000000")
}
files=[
  ('file',('{{file}}.jpeg',open('C:/{{file}}.jpeg','rb'),'image/jpeg'))
]
headers = {}

response = requests.post(url, json=payload)

print(response.text.encode('utf8'))
curl --location '{{apiUrl}}/waInstance{{idInstance}}/setGroupPicture/{{apiTokenInstance}}' \
--form 'file=@"/E:/GreenApi_docs/green-api-logo.png"' \
--form 'chatId="-10000000000000"'
var restTemplate = new RestTemplate();
var requestUrl = new StringBuilder();
requestUrl
    .append({{apiUrl}})
    .append("/waInstance").append({{idInstance}})
    .append("/setGroupPicture/")
    .append({{apiTokenInstance}});

var headers = new HttpHeaders();
headers.setContentType(MediaType.MULTIPART_FORM_DATA);

var form = new LinkedMultiValueMap<>();
form.add("file", new FileSystemResource(new File("/E:/GreenApi_docs/green-api-logo.png")));
form.add("chatId", -10000000000000);

var requestEntity = new HttpEntity<>(form, headers);

var response = restTemplate.exchange(requestUrl.toString(), HttpMethod.POST, requestEntity, String.class);
System.out.println(response);
var requestUrl = new StringBuilder();
requestUrl
    .append({{apiUrl}})
    .append("/waInstance").append({{idInstance}})
    .append("/setGroupPicture/")
    .append({{apiTokenInstance}});

var form = new HashMap<String, Object>();
    form.put("file", new File("/E:/GreenApi_docs/green-api-logo.png"));
    form.put("chatId", dto.getchatId("-10000000000000");

var response = var response = Unirest.post(requestUrl.toString())
    .fields(form)
    .asString();
System.out.println(response);