SetProfilePicture#
The method is aimed for setting an account picture.
Request#
To set an account picture, you have to execute a request at:
POST https://api.greenapi.com/waInstance{{idInstance}}/setProfilePicture/{{apiTokenInstance}}
For 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 = "https://api.greenapi.com/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 'https://api.green-api.com/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("https://api.greenapi.com")
.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("https://api.greenapi.com")
.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 |
---|---|---|
setProfilePicture | boolean | Picture setting result flag |
urlAvatar | string | Set picture url |
reason | string | Reason why the picture hasn't been set |
Response body example#
If successful, in response to the request, a JSON string of the below form with HTTP status 200 is returned:
{
"setProfilePicture": true,
"urlAvatar": "https://pps.whatsapp.net/v/t61.24******-24/23**********_********23704_************77468_n.jpg?ccb=11-4&oh=**********b6ccc377d6332abad7d0bb&oe=********"
}
SetProfilePicture errors#
For a list of errors common to all methods, refer to Common errors section