SendLocation#
The method is aimed for sending location message. The message will be added to the send queue. Linked device not required when sending. Messages will be kept for 24 hours in the queue until instance will be authorized The rate at which messages are sent from the queue is managed by Message sending delay parameter.
Request#
To send location message, you have to execute a request at:
{{apiUrl}}/waInstance{{idInstance}}/sendLocation/{{apiTokenInstance}}
For apiUrl
, idInstance
and apiTokenInstance
request parameters, refer to Before you start section.
Request parameters#
Parameter | Type | Mandatory | Description |
---|---|---|---|
chatId | string | Yes | Chat Id |
nameLocation | string | No | Location name |
address | string | No | Location address |
latitude | double | Yes | Location latitude |
longitude | double | Yes | Location longitude |
quotedMessageId | string | No | Quoted message Id. If present, the message will be sent quoting the specified chat message. Quoting a message is only possible from the same chat to which it is sent. To send messages from another chat, use the ForwardMessages method |
Request body example#
Sending a message to a personal chat:
{
"chatId": "11001234567@c.us",
"nameLocation": "Restaurant",
"address": "123456, Perm",
"latitude": 12.3456789,
"longitude": 10.1112131
}
Sending a message to a group chat:
{
"chatId": "11001234567-1581234048@g.us",
"nameLocation": "Restaurant",
"address": "123456, Perm",
"latitude": 12.3456789,
"longitude": 10.1112131
}
Sending quoted messages:
{
"chatId": "11001234567@c.us",
"nameLocation": "Restaurant",
"address": "123456, Perm",
"latitude": 12.3456789,
"longitude": 10.1112131,
"quotedMessageId": "361B0E63F2FDF95903B6A9C9A102F34B"
}
Response#
Response parameters#
Parameter | Type | Description |
---|---|---|
idMessage | string | Outgoing message Id |
Response body example#
{
"idMessage": "3EB0C767D097B7C7C030"
}
SendLocation errors#
For a list of errors common to all methods, refer to Common errors section
HTTP code | Error identifier | Description |
---|---|---|
400 | Bad Request Validation failed | Validation error |
400 | Validation failed. Details: 'latitude' must be a number or string | Invalid data type for field latitude |
400 | Validation failed. Details: 'latitude' must be a safe number | The value of the field latitude exceeds maximum safe integer value |
500 | Internal Server Error request entity too large | Exceeding the allowed Json length (>100kb) |
Sending with invalid Quoted message ID
If the quotedMessageId
is specified incorrectly, the system will return code 200 and the id of the message, but it will not be delivered to the recipient.
Request examples#
import requests
url = "{{apiUrl}}/waInstance{{idInstance}}/sendLocation/{{apiTokenInstance}}"
payload = {
"chatId": "11001234567@c.us",
"nameLocation": "I'm here",
"address": "613123, Perm",
"latitude": 44.9370129,
"longitude": 89.8728409
}
headers = {
'Content-Type': 'application/json'
}
response = requests.post(url, json=payload, headers=headers)
print(response.text.encode('utf8'))
curl --location '{{apiUrl}}/waInstance{{idInstance}}/sendLocation/{{apiTokenInstance}}' \
--header 'Content-Type: application/json' \
--data-raw '{
"chatId": "12345678910@c.us",
"nameLocation": "Я здесь, приезжай",
"address": "613123, Perm",
"latitude": 44.9370129,
"longitude": 89.8728409
}'
var restTemplate = new RestTemplate();
var requestUrl = new StringBuilder();
requestUrl
.append({{apiUrl}})
.append("/waInstance").append({{idInstance}})
.append("/sendLocation/")
.append({{apiTokenInstance}});
var headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
var jsonBody = "{\r\n \"chatId\": \"11001234567@c.us\",\r\n \"nameLocation\": \"Я здесь, приезжай\",\r\n \"address\": \"613123, Perm\",\r\n \t\"latitude\": 44.9370129,\r\n \"longitude\": 89.8728409\r\n}\r\n";
var requestEntity = new HttpEntity<>(jsonBody, 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("/sendLocation/")
.append({{apiTokenInstance}});
var response = Unirest.post(requestUrl.toString())
.header("Content-Type", "application/json")
.body("{\r\n \"chatId\": \"11001234567@c.us\",\r\n \"nameLocation\": \"Я здесь, приезжай\",\r\n \"address\": \"613123, Perm\",\r\n \t\"latitude\": 44.9370129,\r\n \"longitude\": 89.8728409\r\n}\r\n")
.asString();
System.out.println(response);
Sub SendLocation()
Dim url As String
Dim RequestBody As String
Dim http As Object
Dim response As String
' The apiUrl, idInstance and apiTokenInstance values are available in console, double brackets must be removed
url = "{{apiUrl}}/waInstance{{idInstance}}/sendLocation/{{apiTokenInstance}}"
' chatId - chat identifier, nameLocation - location name, address - location address, latitude - location latitude, longitude - location longitude
RequestBody = "{""chatId"":""71234567890@c.us"",""nameLocation"":""Restaurant"",""address"":""123456, Perm"",""latitude"":12.3456789,""longitude"": 10.1112131}"
Set http = CreateObject("MSXML2.XMLHTTP")
With http
.Open "POST", url, False
.setRequestHeader "Content-Type", "application/json"
.send RequestBody
End With
response = http.responseText
Debug.Print response
' Outputting the answer to the desired cell
Range("A1").Value = response
Set http = Nothing
End Sub