<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html;
      charset=windows-1252">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <p>Dear Thomas,</p>
    <p><br>
    </p>
    <p>After creation invoice you need to downloaded generated invoice
      using call:</p>
    <p><font size="-2"><br>
      </font></p>
    <p><font size="-2">curl -i -X GET -H 'Connection: close' -H 'Accept:
        application/pdf' --user administrator:administrator -k '<a
          class="moz-txt-link-freetext"
          href="https://127.0.0.1:1443/api/invoices/3">https://127.0.0.1:1443/api/invoices/3</a>'
        > /tmp/invoice_3.pdf</font></p>
    <p><br>
    </p>
    <p>Where 3 is a id of the newly generated invoice.</p>
    <p>You can get id from the Location header of the response.</p>
    <p><br>
    </p>
    <p>In console it looks as:</p>
    <p><br>
    </p>
    <p><font size="-2">root@sp1:~# curl -i -X POST -H 'Connection:
        close' -H 'Content-Type: application/json' --user
        administrator:administrator -k
        '<a class="moz-txt-link-freetext" href="https://127.0.0.1:1443/api/invoices/">https://127.0.0.1:1443/api/invoices/</a>' --data-binary '{
        "customer_id" : "139", "template_id" : "1", "period_start":
        "2018-12-01 00:00:00", "period_end": "2018-12-31 23:59:59"  }'<br>
        HTTP/1.1 201 Created<br>
        Server: nginx<br>
        Date: Fri, 25 Jan 2019 14:48:32 GMT<br>
        Content-Length: 0<br>
        Connection: close<br>
        Location: /api/invoices/3<br>
        Set-Cookie:
        ngcp_panel_session=113b2d18ab7886024e5d5caa41b782804dd21164;
        path=/; expires=Fri, 25-Jan-2019 15:48:31 GMT; HttpOnly<br>
        X-Catalyst: 5.90114<br>
        Strict-Transport-Security: max-age=15768000</font><br>
    </p>
    <p><br>
    </p>
    <p>You can see that body really is empty, but header Location tells
      where to get generated invoice.<br>
    </p>
    <p><br>
    </p>
    <p>Please, turn attention on header "Accept" in the request when you
      request generated pdf:</p>
    <p><font size="-2">curl -i -X GET -H 'Connection: close'
      </font><font size="-2"><font size="-2">======></font> -H
        'Accept: application/pdf'<======== --user
        administrator:administrator -k '<a class="moz-txt-link-freetext"
          href="https://127.0.0.1:1443/api/invoices/3">https://127.0.0.1:1443/api/invoices/3</a>'
        > /tmp/invoice_3.pdf</font></p>
    <p><br>
    </p>
    <p><br>
    </p>
    <p>Best regards,</p>
    <p>Irina Peshinskaya<br>
    </p>
    <p><br>
    </p>
    <p><br>
    </p>
    <p><br>
    </p>
    <p><br>
    </p>
    <p><br>
    </p>
    <div class="moz-cite-prefix">On 2019-01-25 14:36, Thomas Georg
      wrote:<br>
    </div>
    <blockquote type="cite"
cite="mid:4137125D652D824496063CCC4506C9B31ACA466E@KRONOS.MSG-Shop.local">
      <meta http-equiv="Content-Type" content="text/html;
        charset=windows-1252">
      <style type="text/css" id="owaParaStyle">P {margin-top:0;margin-bottom:0;}</style>
      <div style="direction: ltr;font-family: Tahoma;color:
        #000000;font-size: 10pt;">Hi list,<br>
        <br>
        I am currently trying to get the invoicing running on SPCE
        6.4.1. Therefore I wrote the following PHP-Script:<br>
        <br>
______________________________________________________________________________________________________________________________<br>
        // Some options<br>
        $auth_username            = 'administrator';<br>
        $auth_password             = SomePassword';<br>
        $url                        =
        '<a class="moz-txt-link-freetext" href="https://siplab:1443/api/invoices/">https://siplab:1443/api/invoices/</a>';<br>
        $header                              = array('Content-Type:
        application/json');<br>
        $curl = curl_init();<br>
        curl_setopt_array($curl, array(<br>
            CURLOPT_SSL_VERIFYPEER => false,<br>
            CURLOPT_SSL_VERIFYHOST => false,<br>
            CURLOPT_RETURNTRANSFER => 1,<br>
            CURLOPT_HTTPHEADER => $header,<br>
            CURLOPT_URL => $url,<br>
            CURLOPT_USERAGENT => 'API-Test',<br>
            CURLOPT_HTTPAUTH=> CURLAUTH_BASIC,<br>
            CURLOPT_USERPWD => "$auth_username:$auth_password",<br>
            CURLOPT_POST => 1,<br>
            CURLOPT_POSTFIELDS => json_encode(array(<br>
                 'customer_id' => 8,<br>
                 'template_id' => 2,<br>
                  'period' => '2018-12'<br>
                                       ))<br>
        ));<br>
        <br>
        // Send the request & save response to $resp<br>
        $resp = curl_exec($curl);<br>
        echo "response: ".$resp;<br>
        echo curl_error($curl);<br>
        var_dump($resp);<br>
        <br>
        // Close request to clear up some resources<br>
        curl_close($curl);<br>
______________________________________________________________________________________________________________________________<br>
        <br>
        The invoice is created but I do not get any response from the
        SPCE. <br>
        <br>
        This is what api.log says:<br>
        <br>
        Jan 25 11:55:09 spce ngcp-panel: INFO: IP=my.client
        CALLED=API[POST]/api/invoices/ TX=157D1210673F6BE8
        USER=administrator DATA={} MSG=""
        LOG="{"customer_id":8,"template_id":2,"period":"2018-09"}"<br>
        Jan 25 11:55:09 spce ngcp-panel: INFO: IP=my.client
        CALLED=API[POST 201]/api/invoices/ TX=157D1210673F6BE8
        USER=administrator DATA={} MSG="" LOG=""<br>
        <br>
        <br>
        I need the response as shown in the API-Documentation to use it
        in other scripts.<br>
        Any ideas? What am I missing?<br>
        <br>
        Regards<br>
        Thomas<br>
        <br>
      </div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <pre class="moz-quote-pre" wrap="">_______________________________________________
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>
  </body>
</html>