Skip to content

SetGroupPicture#

The method sets a group picture.

Request#

To set a group chat picture, you have to execute a request at:

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

For apiUrl, idInstance and apiTokenInstance request parameters, refer to Before you start section.

Request parameters#

Parameter Type Mandatory Description
file file Yes Sent file in *.jpg
groupId string Yes Group chat Id

Request examples#

import requests

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

payload = {'groupId': '12345678910-1112131415@g.us'}
files=[
  ('file',('{{file}}.jpeg',open('C:/{{file}}.jpeg','rb'),'image/jpeg'))
]
headers = {}

response = requests.request("POST", url, headers=headers, data = payload, files=files)

print(response.text.encode('utf8'))
curl --location '{{apiUrl}}/waInstance{{idInstance}}/setGroupPicture/{{apiTokenInstance}}' \
--form 'file=@"/E:/GreenApi_docs/green-api-logo.png"' \
--form 'groupId="120363043968066561@g.us"'
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("groupId", "120363043968066561@g.us");

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("groupId", dto.getGroupId());

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

System.out.println(response);

Response#

Response parameters#

Parameter Type Description
setGroupPicture boolean group picture setting result flag
urlAvatar string set picture url
reason string reason why the picture hasn't been set

Response body example#

{
    "setGroupPicture": true,
    "urlAvatar": "https://pps.whatsapp.net/v/t61.24694-24/138639660_724754321806449_9118612187814397965_n.jpg?oh=997b0bb13b6bbb750432a86d4b8d935d&oe=600****BB4",
    "reason": ""
}

SetGroupPicture errors#

For a list of errors common to all methods, refer to Common errors section