1

Here's the SOAP function:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:v2="http://domain.com/" xmlns:sen="http:/domain.com">
   <soapenv:Header/>
   <soapenv:Body>
      <v2:actionContactsGroup>
         <sen:pInfo>
            <sen:ActionType>?</sen:ActionType>
            <sen:GroupName>?</sen:GroupName>
            <!--Optional:-->
            <sen:ContactIdsList>
               <!--1 or more repetitions:-->
               <sen:Id>?</sen:Id>
            </sen:ContactIdsList>
         </sen:pInfo>
      </v2:actionContactsGroup>
   </soapenv:Body>
</soapenv:Envelope>

If I send over this XML code it works just fine:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:v2="http://domain.com" xmlns:sen="http://domain.com">
   <soapenv:Header/>
   <soapenv:Body>
      <v2:actionContactsGroup>
         <sen:pInfo>
            <sen:ActionType>Add</sen:ActionType>
            <sen:GroupName>MyGroup</sen:GroupName>
            <sen:ContactIdsList>
               <sen:Id>SomeID1</sen:Id>
               <sen:Id>SomeID2</sen:Id>
               <sen:Id>SomeID3</sen:Id>
            </sen:ContactIdsList>
         </sen:pInfo>
      </v2:actionContactsGroup>
   </soapenv:Body>
</soapenv:Envelope>

But I'm unable to do the same in php. I can do it with one id at a time:

$addToGroup = array(
            'pInfo'=>array(
                'ActionType'=>'Add',
                'GroupName'=>'MyGroup',
                'ContactIdsList'=>array('Id'=>'SomeID1')
            )
        );

But if I try multiple ids it doesn't work no matter how I format the array. Ideas?

I tried this but didn't work:

// didnt work, came back saying "Warning: Contact not found
// [Array]WarningDuplicated contact. Only first instance was used."
$addToGroup = array(
        'pInfo'=>array(
            'ActionType'=>'Add',
            'GroupName'=>'NCAL_SUW',
            'ContactIdsList'=>array(
                array('Id'=>'SomeID1'),
                array('Id'=>'SomeID2')
            )
        )
    )
Sergiu Z
  • 153
  • 1
  • 3
  • 12
  • Could it be that you are just missing the ending "semi-colon" ? $addToGroup = array( 'pInfo'=>array( 'ActionType'=>'Add', 'GroupName'=>'NCAL_SUW', 'ContactIdsList'=>array( array('Id'=>'CNANTAM1644583'), array('Id'=>'CNANTAM1644585') ) ) ) `;` – Morfinismo Nov 17 '16 at 21:54
  • Nope, It's not the ending semi-colon. – Sergiu Z Nov 17 '16 at 21:58
  • Possible duplicate of [How to pass an array into a PHP SoapClient call](http://stackoverflow.com/questions/3780543/how-to-pass-an-array-into-a-php-soapclient-call) – Jason Yost Nov 17 '16 at 23:05
  • @JasonYost while I agree that it seems exactly the same, for some reason, the proposed answer doesn't work for me. I've created the array exactly as you'd expect it should be, yet it doesn't work. That's why I ended up posting here. – Sergiu Z Nov 17 '16 at 23:25

1 Answers1

0

I finally figured it out: the array to send out apparently doesn't need to mention the "Id" element. Directly posting a list of ids is enough. So, I ended up using the array below. Why I don't need to mention the "Id" element in my array is beyond me but apparently the soap client takes care of it by itself.

$addToGroup = array(
    'pInfo'=>array(
        'ActionType'=>'Add',
        'GroupName'=>'NCAL_SUW',
        'ContactIdsList'=>array(
            'SomeID1',
            'SomeID2'
        )
    )
)
Sergiu Z
  • 153
  • 1
  • 3
  • 12