<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=utf-8"><meta name=Generator content="Microsoft Word 15 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman",serif;
        color:black;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:#0563C1;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:#954F72;
        text-decoration:underline;}
p
        {mso-style-priority:99;
        mso-margin-top-alt:auto;
        margin-right:0cm;
        mso-margin-bottom-alt:auto;
        margin-left:0cm;
        font-size:12.0pt;
        font-family:"Times New Roman",serif;
        color:black;}
tt
        {mso-style-priority:99;
        font-family:"Courier New";}
span.E-MailFormatvorlage19
        {mso-style-type:personal-reply;
        font-family:"Calibri",sans-serif;
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:70.85pt 70.85pt 2.0cm 70.85pt;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body bgcolor=white lang=DE-AT link="#0563C1" vlink="#954F72"><div class=WordSection1><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US'>Thx, going to be fixed (6.5).<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US'>regards<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US'><o:p> </o:p></span></p><div><div style='border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0cm 0cm 0cm'><p class=MsoNormal><b><span lang=DE style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:windowtext'>Von:</span></b><span lang=DE style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:windowtext'> Spce-user [mailto:spce-user-bounces@lists.sipwise.com] <b>Im Auftrag von </b>Henk<br><b>Gesendet:</b> Donnerstag, 4. Oktober 2018 11:02<br><b>An:</b> spce-user@lists.sipwise.com<br><b>Betreff:</b> [Spce-user] API internal server error 500<o:p></o:p></span></p></div></div><p class=MsoNormal><o:p> </o:p></p><p>Hi,<o:p></o:p></p><p class=MsoNormal style='margin-bottom:12.0pt'>Just started using the API to find out how it works and what can be done with it.<br>So I started with ngcp-credit-warning, added a few print statements and changed the customerbalance call in the main routine:<br><span style='font-size:10.0pt;font-family:"Courier New"'><br><tt>        my @contracts;</tt><br><tt>        get_data(sprintf('/api/customerbalances/?domain=%s&prepaid=1<b>&status=active</b>',</tt><br><tt>            $cwarning->{domain}),</tt><br><tt>            'customerbalances',</tt><br><tt>            sub {</tt><br><tt>            .....</tt><br><br></span>But this first change resulted right away in an internal server error 500. As the documentation suggests this should be reported, this is the API log:<br><tt><span style='font-size:10.0pt'>Oct  4 10:03:14 spce1 ngcp-panel: ERROR: IP=127.0.0.1 CALLED=API[GET 200]/api/customerbalances/ TX=155A591AC89A5910 USER=system DATA={ 'domain' => 'spce.test.nl', 'page' => '1', 'rows' => '10', 'status' => 'active', 'prepaid' => '1'} MSG="" LOG="DBIx::Class::Storage::DBI::_dbh_execute(): DBI Exception: DBD::mysql::st execute failed: <b><u>Column 'status' in where clause is ambiguous</u></b> [for Statement "SELECT COUNT( * ) FROM (SELECT `me`.`id`, `me`.`customer_id`, `me`.`contact_id`, `me`.`order_id`, `me`.`profile_package_id`, `me`.`status`, `me`.`external_id`, `me`.`send_invoice`, `me`.`modify_timestamp`, `me`.`create_timestamp`, `me`.`activate_timestamp`, `me`.`terminate_timestamp`, `me`.`max_subscribers`, `me`.`subscriber_email_template_id`, `me`.`passreset_email_template_id`, `me`.`invoice_email_template_id`, `me`.`invoice_template_id`, `me`.`vat_rate`, `me`.`add_vat`, `billing_mappings`.`id` AS `billing_mappings__id`, `billing_mappings`.`start_date` AS `billing_mappings__start_date`, `billing_mappings`.`product_id` AS `billing_mappings__product_id` FROM `billing`.`contracts` `me` LEFT JOIN (select bm.contract_id,max(bm.id) as actual_bm_id from billing.billing_mappings bm inner join (select bmm.contract_id, max(bmm.start_date) max_start_date from billing.billing_mappings bmm where ( bmm.`end_date` >= ? OR bmm.`end_date` IS NULL ) AND ( bmm.`start_date` <= ? OR bmm.`start_date` IS NULL ) AND ( ? is null OR bmm.`contract_id` = ? ) group by bmm.contract_id ) bmm on bm.contract_id=bmm.contract_id and (bm.start_date=bmm.max_start_date or (bmm.max_start_date is null and bm.start_date is null)) group by bm.contract_id) `billing_mappings_actual` ON `billing_mappings_actual`.`contract_id` = `me`.`id` LEFT JOIN `billing`.`billing_mappings` `billing_mappings` ON `billing_mappings`.`id` = `billing_mappings_actual`.`actual_bm_id` LEFT JOIN `billing`.`billing_profiles` `billing_profile` ON `billing_profile`.`id` = `billing_mappings`.`billing_profile_id` LEFT JOIN `billing`.`voip_subscribers` `voip_subscribers` ON `voip_subscribers`.`contract_id` = `me`.`id` LEFT JOIN `billing`.`domains` `domain` ON `domain`.`id` = `voip_subscribers`.`domain_id` WHERE ( ( `billing_profile`.`prepaid` = ? AND `domain`.`domain` = ? AND `me`.`status` != ? AND `status` = ? ) ) GROUP BY `me`.`id`, `me`.`customer_id`, `me`.`contact_id`, `me`.`order_id`, `me`.`profile_package_id`, `me`.`status`, `me`.`external_id`, `me`.`send_invoice`, `me`.`modify_timestamp`, `me`.`create_timestamp`, `me`.`activate_timestamp`, `me`.`terminate_timestamp`, `me`.`max_subscribers`, `me`.`subscriber_email_template_id`, `me`.`passreset_email_template_id`, `me`.`invoice_email_template_id`, `me`.`invoice_template_id`, `me`.`vat_rate`, `me`.`add_vat`, `billing_mappings`.`id`, `billing_mappings`.`start_date`, `billing_mappings`.`product_id`) `me`" with ParamValues: 0='2018-10-04 10:03:14', 1='2018-10-04 10:03:14', 2=undef, 3=undef, 4=1, 5="spce.voipdigit.nl", 6='terminated', 7="active"] at /usr/share/perl5/NGCP/Panel/Role/API.pm line 617"</span></tt><span style='font-size:10.0pt;font-family:"Courier New"'><br></span><br>Changing the code to <br>        get_data(sprintf('/api/customerbalances/?domain=%s&prepaid=1&<b>contracts</b>.status=active',<br>works, but shouldn't be necessary. Tried this in mr5.5.5 and in mr6.4.1<br><br>Best regards,<br><br>Henk Plessius<o:p></o:p></p></div></body></html>