[Spce-user] Bulk import of billing fees via API

Christian Benke benkokakao at gmail.com
Wed May 27 10:31:32 EDT 2015


After debugging
/usr/share/perl5/NGCP/Panel/Controller/API/BillingFees.pm I found the
issue:

I was using curl with the parameter "--data @filename" which always
worked for me with JSON-files - but for csv-upload this does not work,
as the newlines are removed and the parser receives one long line,
causing the parsing to fail.

Using curl with the parameter "--data-binary  @filename" instead does
not mangle the newlines and the data can be parsed. Also the
boolean-fields must be defined with 0 or 1, not written out.

Here are the required csv-fields in order:
source
destination
direction
zone
zone_detail
onpeak_init_rate
onpeak_init_interval
onpeak_follow_rate
onpeak_follow_interval
offpeak_init_rate
offpeak_init_interval
offpeak_follow_rate
offpeak_follow_interval
use_free_time


Cheers,
Christian

On 27 May 2015 at 10:35, Christian Benke <benkokakao at gmail.com> wrote:
> Andreas,
>
> thanks for the quick answer! I'm running on mr3.8.1, the api.log
> doesn't say much:
>
> May 27 10:32:11 ngcp01 ngcp-panel: INFO: IP=192.168.169.126
> CALLED=API[POST 201]/api/billingfees/ TX=13E2072F61812530 USER=benke
> DATA={ 'purge_existing' => 'true', 'billing_profile_id' => '12'}
> MSG="" LOG=""
>
> On 26 May 2015 at 14:45, Andreas Granig <agranig at sipwise.com> wrote:
>> Hi,
>>
>> Well, what's the CE version you're working with, and what does
>> /var/log/ngcp/api.log tells you?
>>
>> Andreas
>>
>> On 05/26/2015 02:23 PM, Christian Benke wrote:
>>> Hello!
>>>
>>> I'm trying to figure out the correct csv-format to bulk update rates
>>> via the API, as defined in the API-documentation [1]. While it got it
>>> working fine via the CSV-upload in the webinterface, the same format
>>> does not work for the API. I have found several threads defining the
>>> format for the webinterface-upload-option (e.g.
>>> https://lists.sipwise.com/pipermail/spce-user/2012-July/001708.html),
>>> but none that details how the csv has to look like to do a bulk update
>>> via the API.
>>>
>>> Aside from using the same format that works for the
>>> webinterface-upload, I also tried to setup the csv-fields in the order
>>> given in the API-docs (With billing_zone_id), but that only gives me
>>> "Billing Fee successfully uploaded, but skipped the following line
>>> numbers: 1":
>>>
>>> billing_zone_id, destination,direction,offpeak_follow_interval,
>>> offpeak_follow_rate,offpeak_init_interval,offpeak_init_rate,onpeak_follow_interval,onpeak_follow_rate,onpeak_init_interval,onpeak_init_rate,purge_existing,source,use_free_time
>>> 11637,^9371.+$,out,1,0.187933,1,0.187933,1,0.187933,1,0.187933,true,.,false
>>> 10661,^26371.+$,out,1,0.463017,1,0.463017,1,0.463017,1,0.463017,true,.,false
>>>
>>> (I've also tried true/false for the bool-values, to no avail).
>>>
>>> Could someone please specify what the correct csv-field-format would
>>> be for bulk fees update via the API?
>>>
>>>
>>> [1] "To bulk-upload fees, specify the Content-Type as "text/csv" and
>>> POST the CSV in the request body to the collection while specifying
>>> the the billing profile via URI parameters, like
>>> "/api/billingfees/?billing_profile_id=xx&purge_existing=true""
>>>
>>> Thanks & best regards,
>>> Christian
>>> _______________________________________________
>>> Spce-user mailing list
>>> Spce-user at lists.sipwise.com
>>> https://lists.sipwise.com/listinfo/spce-user
>>>
>> _______________________________________________
>> Spce-user mailing list
>> Spce-user at lists.sipwise.com
>> https://lists.sipwise.com/listinfo/spce-user



More information about the Spce-user mailing list