Skip to content

SetProfilePicture#

The method is aimed for setting an account picture.

Request#

To set an account picture, you have to execute a request at:

POST {{apiUrl}}/waInstance{{idInstance}}/setProfilePicture/{{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

Request examples#

import requests

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

payload={}
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)
curl --location '{{apiUrl}}/waInstance{{idInstance}}/setProfilePicture/{{apiTokenInstance}}' \
--form 'file=@"Users/path/to/file"'
var file = new File("Users/path/to/file");
var restTemplate = new RestTemplate();

var requestUrl = new StringBuilder();
requestUrl
    .append({{apiUrl}})
    .append("/waInstance").append({{idInstance}})
    .append("/setProfilePicture/")
    .append({{apiTokenInstance}});

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

var form = new LinkedMultiValueMap<>();
form.add("file", new FileSystemResource(file));

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

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

var response = Unirest.post(requestUrl.toString())
    .field("file", file, Files.probeContentType(file.toPath()))
    .asString();

System.out.println(response);

Response#

Response parameters#

Parameter Type Description
reason string Reason why the picture hasn't been set
urlAvatar string Set picture url
setProfilePicture boolean Picture setting result flag

Response body example#

If successful, in response to the request, a JSON string of the below form with HTTP status 200 is returned:

{
    "reason": null,
    "urlAvatar": "https://pps.whatsapp.net/v/t61.24******-24/23**********_********23704_************77468_n.jpg?ccb=11-4&oh=**********b6ccc377d6332abad7d0bb&oe=********",
    "setProfilePicture": true
}

SetProfilePicture errors#

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