SOAP wsdl create new user with custom fields

SOAP wsdl create new user with custom fields

by Roberto Martínez -
Number of replies: 0

Hi dear moodle-gurus:

I am recently trying to crate users using a SOAP call and a wsdl, but the thing is that I can't figure out how to create a new user with custom fields. If I create a new user without the custom fields it creates succesfully.


Here's what I've been doing:

<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ser="http:XXXXXXXX/soap/server.php?wstoken=XXXXXX">

   <soapenv:Header/>

   <soapenv:Body>

      <ser:core_user_create_users soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">

         <users xsi:type="soapenc:Array" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">

             <Item soapenc:id="id1">

               <username xsi:type="xsd:string">holauseron</username>

               <password xsi:type="xsd:string">Description_1.</password>

               <firstname xsi:type="xsd:string">Juan</firstname>

               <lastname xsi:type="xsd:string">Perez</lastname>

               <email xsi:type="xsd:string">johnycasszzh1@example.com</email>

               <auth xsi:type="xsd:string">manual</auth>

            </Item>

         </users>

      </ser:core_user_create_users>

   </soapenv:Body>

</soapenv:Envelope> 

This call is successful but if I do this:

   <soapenv:Header/>
   <soapenv:Body>
      <ser:core_user_create_users soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
         <users xsi:type="soapenc:Array" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
             <Item soapenc:id="id1">
               <username xsi:type="xsd:string">adiosuserin</username>
               <password xsi:type="xsd:string">Description_1.</password>
               <firstname xsi:type="xsd:string">Juan</firstname>
               <lastname xsi:type="xsd:string">Perez</lastname>
               <email xsi:type="xsd:string">junitodineroz@example.com</email>
               <auth xsi:type="xsd:string">manual</auth>
               <customfields xsi:type="xsd:list">
                <type xsi:type="xds:string">idasociado</type>
                <value xsi:type="xds:string">128157</value>
                <type xsi:type="xds:string">razonsocial</type>
                <value xsi:type="xds:string">GS1 MEXICO</value>
                <type xsi:type="x
                ds:string">ramoindustrial</type>
                <value xsi:type="xds:string">M1</value>
                <type xsi:type="xds:string">subtipo</type>
                <value xsi:type="xds:string">Servicio Membresía Única</value>
                <type xsi:type="xds:string">statusempresa</type>
                <value xsi:type="xds:string">Asociado</value>
                <type xsi:type="xds:string">entidadfederativa</type>
                <value xsi:type="xds:string">MEX</value>
                <type xsi:type="xds:string">idcontacto</type>
                <value xsi:type="xds:string">8142423</value>
               </customfields>

            </Item>
         </users>
      </ser:core_user_create_users>
   </soapenv:Body>
</soapenv:Envelope>

I get:


<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
   <SOAP-ENV:Body>
      <SOAP-ENV:Fault>
         <faultcode>Receiver</faultcode>
         <faultstring>Invalid parameter value detected | ERRORCODE: invalidparameter</faultstring>
         <faultactor>invalidparameter</faultactor>
      </SOAP-ENV:Fault>
   </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

Average of ratings: -