Skip to content

SetProfilePicture#

Test Postman Apidog

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

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

HTTP code Error identifier Description
200 rate-overlimit Call the SetProfilePicture method no more than once time in 10 seconds, this is a limitation on WhatsApp servers. The request limit for all methods is indicated in the table
400 File is empty File is empty
400 Unsupported media type Unsupported media type

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.post(url, json=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);