<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">Hi,<div class=""><br class=""></div><div class="">OK, thank you for the tip. Now it works!</div><div class=""><br class=""></div><div class="">Thanks,</div><div class="">Walter</div><div class=""><br class=""><div class=""><div style="color: rgb(0, 0, 0); letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div style="color: rgb(0, 0, 0); letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><table class="x_MsoNormalTable" border="0" cellspacing="0" cellpadding="0" width="400" style="font-family: Helvetica; letter-spacing: normal; text-indent: 0px; text-transform: none; word-spacing: 0px; -webkit-text-stroke-width: 0px; width: 259.8pt;"><tbody class=""><tr class=""><td valign="top" class="" style="padding: 0in;"><br class=""></td></tr></tbody></table></div></div>
</div>
<div><br class=""><blockquote type="cite" class=""><div class="">On 12 May 2018, at 2:21 AM, Irina Peshinskaya <<a href="mailto:ipeshinskaya@sipwise.com" class="">ipeshinskaya@sipwise.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class="">
  
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" class="">
  
  <div text="#000000" bgcolor="#FFFFFF" class="">
    Dear Walter,<br class="">
    <br class="">
    Here is example of command line curl call to terminate customer:<br class="">
    <br class="">
    <blockquote class=""><font size="-2" class="">root@sp1:~# curl -i -k -X PATCH -H
        'Connection: close' -H 'Content-Type:
        application/json-patch+json'  --user administrator:administrator
        '<a class="moz-txt-link-freetext" href="https://127.0.0.1:1443/api/customers/221">https://127.0.0.1:1443/api/customers/221</a>' --data-binary '[{
        "op" : "replace", "path" : "/status", "value" : "terminated" }]'<br class="">
        HTTP/1.1 204 No Content<br class="">
        Server: nginx<br class="">
        Date: Fri, 11 May 2018 18:17:08 GMT<br class="">
        Connection: close<br class="">
        Preference-Applied: return=minimal<br class="">
        Set-Cookie:
        ngcp_panel_session=826f204486c1123b1af0a7482d7735cdde1e889b;
        path=/; expires=Fri, 11-May-2018 19:17:07 GMT; HttpOnly<br class="">
        X-Catalyst: 5.90114<br class="">
        Strict-Transport-Security: max-age=15768000<br class="">
      </font><br class="">
      <font size="-2" class=""><font size="-2" class="">root@sp1:~# </font></font></blockquote>
    <br class="">
    <br class="">
    I see the difference that your content is JSON object, but API
    expects an array of objects, like in example. So
    <div class=""><br class="">
                      $jsonDataEncoded = "{ 'op' : 'replace', 'path' :
      '/status', 'value' : 'terminated' }";</div>
    <div class=""><br class="">
      should be<br class="">
      <br class="">
      <div class="">                $jsonDataEncoded = "[ { 'op' :
        'replace', 'path' : '/status', 'value' : 'terminated' } ]";</div>
      <div class=""><br class="">
      </div>
    </div>
    Best regards,<br class="">
    Irina Peshinskaya<br class="">
    <br class="">
    <div class="moz-cite-prefix">On 2018-05-11 18:30, Walter Klomp
      wrote:<br class="">
    </div>
    <blockquote type="cite" cite="mid:F56959C9-129B-4D97-A1BA-5DD3EDC2240C@myrepublic.net" class="">Hi,
      <div class=""><br class="">
      </div>
      <div class="">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</div>
      <div class=""><br class="">
      </div>
      <div class=""><a href="https://www.sipwise.com/doc/mr6.2.1/spce/ar01s10.html" class="" moz-do-not-send="true">https://www.sipwise.com/doc/mr6.2.1/spce/ar01s10.html</a>
        , but then in PHP…  </div>
      <div class=""><br class="">
      </div>
      <div class="">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…</div>
      <div class=""><br class="">
      </div>
      <div class="">Below is the snippet of code I am executing…. </div>
      <div class=""><br class="">
      </div>
      <div class=""><br class="">
      </div>
      <div class="">
        <div class=""><span class="Apple-tab-span" style="white-space:pre">           </span>echo
          "Terminating customer id $customer_id ...";</div>
        <div class=""><br class="">
        </div>
        <div class="">
          <div class="">                $url = "<a href="https://$host:1443/api/customers/$customer_id" class="" moz-do-not-send="true">https://$host:1443/api/customers/$customer_id</a>";</div>
          <div class=""><br class="">
          </div>
          <div class="">                //Initiate cURL.</div>
          <div class="">                $ch = curl_init($url);</div>
          <div class=""><br class="">
          </div>
          <div class="">                //The JSON data.</div>
          <div class="">                $jsonDataEncoded = "{ 'op' :
            'replace', 'path' : '/status', 'value' : 'terminated' }";</div>
          <div class=""><br class="">
          </div>
          <div class="">                curl_setopt($ch,
            CURLOPT_USERPWD,”$user:$pw");</div>
          <div class="">                curl_setopt($ch,
            CURLOPT_RETURNTRANSFER,true);</div>
          <div class=""><br class="">
          </div>
          <div class="">                curl_setopt($ch,
            CURLOPT_CUSTOMREQUEST, 'PATCH');</div>
          <div class=""><br class="">
          </div>
          <div class="">                //Attach our encoded JSON string
            to the POST fields.</div>
          <div class="">                curl_setopt($ch,
            CURLOPT_POSTFIELDS, $jsonDataEncoded);</div>
          <div class=""><br class="">
          </div>
          <div class="">                //Set the content type to
            application/json</div>
          <div class="">                curl_setopt($ch,
            CURLOPT_HTTPHEADER, array('Content-Type:
            application/json'));</div>
          <div class="">                curl_setopt($ch, CURLOPT_HEADER,
            TRUE);</div>
        </div>
        <div class=""><br class="">
        </div>
        <div class="">/*</div>
        <div class="">  Let's get the Response !</div>
        <div class="">*/</div>
        <div class="">$api_response = curl_exec($ch);</div>
        <div class=""><br class="">
        </div>
        <div class="">/*</div>
        <div class="">  We need to get Curl infos for the header_size
          and the http_code</div>
        <div class="">*/</div>
        <div class="">$api_response_info = curl_getinfo($ch);</div>
        <div class="">/*</div>
        <div class="">  Here we separate the Response Header from the
          Response Body</div>
        <div class="">*/</div>
        <div class="">$api_response_header = trim(substr($api_response,
          0, $api_response_info['header_size']));</div>
        <div class="">$api_response_body = substr($api_response,
          $api_response_info['header_size']);</div>
        <div class=""><br class="">
        </div>
        <div class="">// Response HTTP Status Code</div>
        <div class="">echo $api_response_info['http_code'];</div>
        <div class=""><br class="">
        </div>
        <div class="">// Response Header</div>
        <div class="">echo $api_response_header;</div>
        <div class=""><br class="">
        </div>
        <div class="">// Response Body</div>
        <div class="">echo $api_response_body;</div>
        <div class=""><br class="">
        </div>
        <div class="">exit;</div>
      </div>
      <div class=""><br class="">
      </div>
      <div class=""><br class="">
      </div>
      <div class=""><br class="">
      </div>
      <div class="">———</div>
      <div class=""><br class="">
      </div>
      <div class="">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.</div>
      <div class=""><br class="">
      </div>
      <div class="">Am I missing something ?   Do I need to set
        something somewhere to enable deletion ?</div>
      <div class=""><br class="">
      </div>
      <div class="">Hope anybody can help.</div>
      <div class=""><br class="">
      </div>
      <div class="">Thank you</div>
      <div class="">Walter Klomp</div>
      <div class=""><br class="">
      </div>
      <div class=""><br class="">
      </div>
      <div class=""><br class="">
      </div>
      <br class="">
      <br class="">
      <div class="">
        <div style="letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">
          <div style="letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">
            <table class="MsoNormalTable" style="font-family: Helvetica;
              letter-spacing: normal; text-indent: 0px; text-transform:
              none; word-spacing: 0px; -webkit-text-stroke-width: 0px;
              width: 259.8pt;" cellspacing="0" cellpadding="0" width="346" border="0">
              <tbody class="">
                <tr class="">
                  <td style="padding: 0cm;" class="" valign="top">
                    <div style="margin: 0cm 0cm 0.0001pt; font-size:
                      12pt; font-family: 'Times New Roman';" class=""><br class="">
                    </div>
                    <div style="margin: 0cm 0cm 0.0001pt; font-size:
                      12pt; font-family: 'Times New Roman';" class="">Warmest
                      Regards,</div>
                    <div style="margin: 0cm 0cm 0.0001pt; font-size:
                      12pt; font-family: 'Times New Roman';" class=""><span style="color: purple; text-decoration: none;" class=""><a href="https://myrepublic.com.sg/" target="_blank" style="color: purple;" class="" moz-do-not-send="true"><br class="Apple-interchange-newline">
                          <img id="_x0000_i1027" src="https://myrepublic.com.sg/resources/email-signature.png" class="" moz-do-not-send="true" height="92" width="140" border="0"></a></span><o:p class=""></o:p></div>
                  </td>
                  <td style="padding: 0cm;" class="">
                    <div style="margin: 0cm 0cm 0.0001pt; font-size:
                      12pt; font-family: 'Times New Roman';" class=""><b class=""><span style="font-size: 10pt;
                          font-family: Arial; color: rgb(127, 43, 153);" class="">Walter Klomp</span></b><o:p class=""></o:p></div>
                    <div style="margin: 0cm 0cm 0.0001pt; font-size:
                      12pt; font-family: 'Times New Roman';" class=""><span style="font-size: 8.5pt; font-family: Arial;
                        color: rgb(77, 77, 77);" class="">Head of Voice</span><o:p class=""></o:p></div>
                    <div style="margin: 0cm 0cm 0.0001pt; font-size:
                      12pt; font-family: 'Times New Roman';" class=""><span style="font-size: 8.5pt; font-family: Arial;
                        color: rgb(77, 77, 77);" class="">MyRepublic
                        Limited</span><o:p class=""></o:p></div>
                    <div style="margin: 0cm 0cm 0.0001pt; font-size:
                      12pt; font-family: 'Times New Roman';" class=""><span style="font-size: 8.5pt; font-family: Arial;
                        color: rgb(77, 77, 77);" class="">T: +65 6816
                        1120</span><o:p class=""></o:p></div>
                    <div style="margin: 0cm 0cm 0.0001pt; font-size:
                      12pt; font-family: 'Times New Roman';" class=""><span style="font-size: 8.5pt; font-family: Arial;
                        color: rgb(77, 77, 77);" class="">F: +65 6717
                        2031</span></div>
                  </td>
                </tr>
                <tr class="">
                  <td colspan="2" style="width: 249.75pt; padding: 0cm;" class="" width="333">
                    <div style="margin: 0cm 0cm 0.0001pt; font-size:
                      12pt; font-family: 'Times New Roman';" class=""> <o:p class=""></o:p></div>
                    <div style="margin: 0cm 0cm 0.0001pt; font-size:
                      12pt; font-family: 'Times New Roman';" class=""><span style="font-size: 8.5pt; font-family: Arial;
                        color: rgb(77, 77, 77);" class="">MyRepublic
                        Limited</span><o:p class=""></o:p></div>
                    <div style="font-family: arial, sans-serif;
                      font-size: 16px; margin: 0in 0in 0.0001pt;" class=""><font class="" face="Arial, sans-serif" color="#4d4d4d"><span style="font-size:
                          11.3333px;" class="">11 Lorong 3 Toa Payoh
                          Block B Jackson Square</span></font></div>
                    <div style="font-family: arial, sans-serif;
                      font-size: 16px; margin: 0in 0in 0.0001pt;" class=""><font class="" face="Arial, sans-serif" color="#4d4d4d"><span style="font-size:
                          11.3333px;" class="">#04-11/15 Singapore
                          319579</span></font></div>
                    <div style="margin: 0cm 0cm 0.0001pt; font-size:
                      12pt; font-family: 'Times New Roman';" class=""><span style="font-size: 8.5pt; font-family: Arial;
                        color: rgb(77, 77, 77);" class=""><br class="">
                      </span><span style="color: rgb(77, 77, 77);" class=""><a href="https://myrepublic.com.sg/" target="_blank" style="color: purple;" class="" moz-do-not-send="true"><span style="font-size: 8.5pt; font-family: Arial;
                            color: rgb(77, 77, 77);" class="">myrepublic.com.sg</span></a></span><o:p class=""></o:p></div>
                    <div style="margin: 0cm 0cm 0.0001pt; font-size:
                      12pt; font-family: 'Times New Roman';" class=""><span style="font-size: 8.5pt; font-family: Arial;
                        color: rgb(77, 77, 77);" class="">Follow us on: <a href="https://twitter.com/myrepublic" target="_blank" style="color: purple;" class="" moz-do-not-send="true"><span style="color: rgb(77, 77, 77);" class="">Twitter</span></a> | <a href="https://facebook.com/myrepublicsg" target="_blank" style="color: purple;" class="" moz-do-not-send="true"><span style="color: rgb(77, 77, 77);" class="">Facebook</span></a> | <a href="https://www.linkedin.com/company/myrepublic" style="color:
                          purple;" class="" moz-do-not-send="true"><span style="color: rgb(5, 99, 193);" class="">LinkedIn</span></a></span></div>
                  </td>
                </tr>
              </tbody>
            </table>
            <div style="font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br class="">
            </div>
            <table class="x_MsoNormalTable" style="font-family:
              Helvetica; letter-spacing: normal; text-indent: 0px;
              text-transform: none; word-spacing: 0px;
              -webkit-text-stroke-width: 0px; width: 259.8pt;" cellspacing="0" cellpadding="0" width="400" border="0">
              <tbody class="">
                <tr class="">
                  <td class="" style="padding: 0in;" valign="top"><br class="">
                  </td>
                </tr>
              </tbody>
            </table>
          </div>
        </div>
      </div>
      <br class="">
      <br class="">
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br class="">
      <pre wrap="" class="">_______________________________________________
Spce-user mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Spce-user@lists.sipwise.com">Spce-user@lists.sipwise.com</a>
<a class="moz-txt-link-freetext" href="https://lists.sipwise.com/listinfo/spce-user">https://lists.sipwise.com/listinfo/spce-user</a>
</pre>
    </blockquote>
    <br class="">
  </div>

</div></blockquote></div><br class=""></div></body></html>