How to delete company using XML-RPC?

BACKGROUND
This is a follow-up from this previous question of mine.
Since the answer to that question suggested to use XML-RPC instead.

I NEED
to perform Delete operation to Companies.

I TRIED
Doing what this suggested.

XML File

 <?xml version='1.0' encoding='UTF-8'?>
 <methodCall>
   <methodName>DataService.delete</methodName>
   <params>
     <param>
       <value>
         <string>xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx</string>
       </value>
     </param>
     <param>
       <value>
         <string>Company</string>
       </value>
     </param>
     <param>
       <value>
         <int>25</int>
       </value>
     </param>
   </params>
 </methodCall>

Laravel PHP Code

  $xml = simplexml_load_file('C:\path\to\temp.xml');

    $fullTokenObj = unserialize(auth()->user()->token);
    $connection_URL = 'https://api.infusionsoft.com/crm/xmlrpc/v1/?access_token='
        . $fullTokenObj->getAccessToken();

    $client = new GuzzleClient();
    $response = $client->request('POST', $connection_URL, [
      'headers' => [
          'Content-Type' => 'text/xml; charset=UTF8',
      ],
    	'body' => $xml
    ]);

    dd($response);

But the response just returns:

Response {#594
-reasonPhrase: “OK”
-statusCode: 200
-headers: array:25 [:arrow_forward:]
-headerNames: array:25 [:arrow_forward:]
-protocol: “1.1”
-stream: Stream {#592 :arrow_forward:}
}

When I get the list of companies using REST, there was no change in the companies list. Company ID#25 is not deleted.

QUESTION
I’m not sure which part I may have missed. I also tried adding a company suggested there too. but the new company is not reflected. Is there another configuration setting in order to use XML-RPC?

@Garik_Tate,

It would be far easier to use the data service object using the api SDK. you can use the dsDelete/Delete method straight out rather that recreating the wheel. It will allow you to remove the company record by directly addressing the Company table.

@John_Borelli
Thank you for your reply. The DataService object nailed it!

$infusionsoft->data()->delete(‘Company’, 21); // this works!

For future reference, I found that the CompanyService doesn’t allow FIND and DELETE for some reason.

class CompanyService extends RestModel
{
use CannotSync, CannotDelete, CannotFind;
…}

1 Like