[Spce-user] REST API customer terminate not working...

Walter Klomp walter at myrepublic.net
Fri May 11 12:30:25 EDT 2018


Hi,

I require a bit of help. I am trying to write some modules to convert from SOAP to rest and I am following the example on

https://www.sipwise.com/doc/mr6.2.1/spce/ar01s10.html , but then in PHP…  

I have managed to write the create contact, customer and subscriber, and set preferences, but now I am trying to DELETE them, and I get no response on that request…

Below is the snippet of code I am executing…. 


		echo "Terminating customer id $customer_id ...";

                $url = "https://$host:1443/api/customers/$customer_id";

                //Initiate cURL.
                $ch = curl_init($url);

                //The JSON data.
                $jsonDataEncoded = "{ 'op' : 'replace', 'path' : '/status', 'value' : 'terminated' }";

                curl_setopt($ch, CURLOPT_USERPWD,”$user:$pw");
                curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);

                curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PATCH');

                //Attach our encoded JSON string to the POST fields.
                curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonDataEncoded);

                //Set the content type to application/json
                curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
                curl_setopt($ch, CURLOPT_HEADER, TRUE);

/*
  Let's get the Response !
*/
$api_response = curl_exec($ch);

/*
  We need to get Curl infos for the header_size and the http_code
*/
$api_response_info = curl_getinfo($ch);
/*
  Here we separate the Response Header from the Response Body
*/
$api_response_header = trim(substr($api_response, 0, $api_response_info['header_size']));
$api_response_body = substr($api_response, $api_response_info['header_size']);

// Response HTTP Status Code
echo $api_response_info['http_code'];

// Response Header
echo $api_response_header;

// Response Body
echo $api_response_body;

exit;



———

I know the customer_id is a valid number, but I get no response from the server, http_code=0, and nothing in the headers and body.  (which is why I put the extended code in) - I also see nothing in API.php.     I have even checked if the username of the account is “master”, and it is, so it should have the right to do this.

Am I missing something ?   Do I need to set something somewhere to enable deletion ?

Hope anybody can help.

Thank you
Walter Klomp






Warmest Regards,

 <https://myrepublic.com.sg/>	
Walter Klomp
Head of Voice
MyRepublic Limited
T: +65 6816 1120
F: +65 6717 2031
 
MyRepublic Limited
11 Lorong 3 Toa Payoh Block B Jackson Square
#04-11/15 Singapore 319579

myrepublic.com.sg <https://myrepublic.com.sg/>
Follow us on: Twitter <https://twitter.com/myrepublic> | Facebook <https://facebook.com/myrepublicsg> | LinkedIn <https://www.linkedin.com/company/myrepublic>



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sipwise.com/mailman/private/spce-user_lists.sipwise.com/attachments/20180512/c0804f5e/attachment.html>


More information about the Spce-user mailing list