Python Integration
Webhook
$ pip install Flask
webhook.py
from flask import Flask, request, jsonify, make_response
import json, os
app = Flask(__name__)
@app.route('/data', methods = ['POST', 'GET'])
def data():
data = request.json
data_string = json.dumps(data)
data_json = json.loads(data_string)
print(data_json, file=open("output.txt", "a"))
return make_response("",200)
if __name__ == "__main__":
app.run(host = '127.0.0.1', port='3000', debug=True)
python webhook.py
#running in background
nohup python webhook.py > captodocs.log 2>&1 &
Ejemplo de datos guardados en output.txt
output.txt
{
"AccountingUser": "ADMIN",
"Company": "1",
"Department": "1",
"Division": "1",
"Holding": "HOLDING1",
"Journal": "400",
"LocalCurrency": "EUR",
"Monbas": "2",
"Posting": "1",
"Token": "4R33vj9EdJHsdaAE74345fDsW",
"Detail": "1",
"Impost": "1",
"Name": "Alquiler local",
"Pagapu": "1",
"PaymentAutomatic": "0",
"PaymentClacre": "03",
"PaymentOnAccount": "572000003",
"PaymentOnAccountAuxcod": "",
"PaymentOnAccountAuxtip": "",
"SellerAccount": "410000003",
"SellerAuxiliary": "",
"SellerAuxiliaryAuxcod": "",
"SellerConamp": "Alquiler y servicios mes",
"SellerConcep": "02",
"Tipfac": "PR",
"SellerPartyCorporateName": "Alquileres, S.L.",
"SellerAddress": "Av Diagonal, 1234",
"SellerAddressPostCode": "08173",
"SellerAddessTown": "Barcelona",
"SellerTaxIdentification": "B00000000",
"SellerEmail": "seller@email.com",
"SelletTel": "0000000000000",
"InvoiceNumber": "5158",
"InvoiceIssueDate": "20190110",
"BuyerPartyCorporateName": "Empresa, S.L.",
"BuyerAddress": "Av Diagonal, 1234",
"BuyesAddressPostCode": "08173",
"BuyesAddressTown": "Barcelona",
"BuyerAddressProvince": "Barcelona",
"BuyerTaxIdentification": "B00000000",
"Detail1ArticleCode": "Renta Octubre",
"Detail1TotalCost": "819,30",
"Detail2ArticleCode": "Gastos Comunes",
"Detail2TotalCost": "219,59",
"InvoiceTotalsGrossAmount": "1038,89",
"Tax1Rate": "21,00",
"Tax1TotalAmount": "218,17",
"TotalInvoiceAmount": "1257,06",
"Detail1": {
"DetailAccount": "62100001",
"DetailAuxiliary": "",
"DetailAuxiliaryAuxcod": "",
"DetailConamp": "Alquiler",
"DetailConcep": "02",
"DetailCurrency": "EUR"
},
"Detail2": {
"DetailAccount": "62100001",
"DetailAuxiliary": "",
"DetailAuxiliaryAuxcod": "",
"DetailConamp": "Suministros",
"DetailConcep": "02",
"DetailCurrency": "EUR"
},
"Tax1": {
"TaxAccountTax": "47200000",
"TaxAuxapu": "0",
"TaxAuxcod": "",
"TaxAuxtip": "",
"TaxClaopr": "",
"TaxColimp": "1",
"TaxCurrency": "EUR",
"TaxLibreg": "SOP",
"TaxRelaci": "RG",
"TaxType": "1"
},
"TotalInvoice": {
"TotalInvoiceAccounting": "62100001",
"TotalInvoiceAuxapu": "0",
"TotalInvoiceAuxcod": "",
"TotalInvoiceAuxtip": "",
"TotalInvoiceCurrency": "EUR"
}
}
Última actualización
¿Te fue útil?