Skip to content

AddGroupParticipant#

Test

השיטה מוסיפה משתתף לצ'אט קבוצתי.

Important

Only the administrator can add members, change the name and make other changes. If you are not the group administrator, the method will return an error.

בַּקָשָׁה#

כדי להוסיף משתתף לצ'אט קבוצתי, עליך לבצע בקשה בכתובת:

POST
{{apiUrl}}/waInstance{{idInstance}}/addGroupParticipant/{{apiTokenInstance}}
TEST

לפרמטרים של בקשת apiUrl, idInstance ו-apiTokenInstance, עיין ב לפני שמתחילים section.

בקש פרמטרים#

פָּרָמֶטֶר סוּג הֶכְרֵחִי תֵאוּר
groupId string כֵּן זיהוי צ'אט קבוצתי
participantChatId string כֵּן Id of a participant added to a group chat.

דוגמה לגוף תגובה#

הוספת משתתף לצ'אט קבוצתי:

{
    "groupId": "11001234567-1587570015@g.us",
    "participantChatId": "79001234565@c.us"
}

תְגוּבָה#

פרמטרי תגובה#

פָּרָמֶטֶר סוּג תֵאוּר
addParticipant boolean דגל המציין הוספת משתתף לצ'אט קבוצתי

Why is the request response false?

The response to the request or the value of addParticipant can be false for three reasons:

  1. The user attempting to add a new participant to the group does not have the status of an administrator for that group.
  2. The user adding a new participant to the group does not have the participant's number saved in their phonebook.
  3. The contact is already a member of the group.

While some numbers can be added to the group without being saved in the phonebook, it is recommended to always pre-save the participant's phone number in the contacts list to ensure successful addition to the group.

דוגמה לגוף תגובה#

{
    "addParticipant": true
}

AddGroupParticipant שגיאות#

לרשימה של שגיאות משותפות לכל השיטות, עיין ב שגיאות נפוצות סָעִיף

טקסט תגובה לדוגמה#

import requests

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

payload = "{\r\n\t\"groupId\": \"11001234567-1581234048@g.us\",\r\n\t\"participantChatId\": \"79001234568@c.us\"\r\n}"
headers = {
  'Content-Type': 'application/json'
}

response = requests.post(url, json=payload)

print(response.text.encode('utf8'))
curl --location '{{apiUrl}}/waInstance{{idInstance}}/addGroupParticipant/{{apiTokenInstance}}' \
--header 'Content-Type: application/json' \
--data-raw '{
    "groupId": "111111112222222333333@g.us",
    "participantChatId": "12345678910@c.us"
}'
var restTemplate = new RestTemplate();
var requestUrl = new StringBuilder();
requestUrl
    .append({{apiUrl}})
    .append("/waInstance").append({{idInstance}})
    .append("/addGroupParticipant/")
    .append({{apiTokenInstance}});

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

var jsonBody = "{\"groupId\": \"111111112222222333333@g.us\",\"participantChatId\": \"12345678910@c.us\"}";

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("/addGroupParticipant/")
    .append({{apiTokenInstance}});

var response = Unirest.post(requestUrl.toString())
    .header("Content-Type", "application/json")
    .body("{\"groupId\": \"111111112222222333333@g.us\",\"participantChatId\": \"12345678910@c.us\"}")
    .asString();

System.out.println(response);
Sub AddGroupParticipant()
    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}}/addGroupParticipant/{{apiTokenInstance}}"

    ' groupId - group chat identifier, participantChatId - identifier of the participant added to the group chat
    RequestBody = "{""groupId"":""120123400367448864@g.us"",""participantChatId"":""70123456789@c.us""}"

    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