[go: up one dir, main page]

Skip to content

SetGroupPicture#

Test Postman

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

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

HTTP code Error identifier Description
200 {
"reason": "Timed Out",
"urlAvatar": null,
"setGroupPicture": false
}
Incorrect data type for field groupId

or incorrect groupId
400 Bad Request
Validation failed
Validation error
400 File is empty File is empty
400 Unsupported media type Unsupported media type

Request examples#

import requests

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

payload = {(
    "groupId": "11011234567@g.us")
}
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 '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);