sendXmlAsFile()
Metodo per inviare una fattura al SDI direttamente in formato file XML.
Endpoint
Method |
URI |
POST |
https://fatture.keliweb.it/api/send-xml-file |
Request Parameters
Parameter |
Type |
Description |
Required |
HTTP headers: Authorization |
string |
Bearer + the token to access APIs |
Yes |
xml |
file |
Il file in formato XML |
Yes |
Response Parameters
Parameter |
Type |
Description |
status |
string |
risultato dell'operazione (success / errors ) |
message |
string |
dettagli sul risultato dell'operazione |
invoiceData |
array |
dati relativi alla fattura appena inviata (status, nome file, ID, progressivo, etc.) |
sdi |
array |
dati specifici del SDI, come IdentificativoSdI e DataOraRicezione |
Example Request (BASH Curl)
curl --location --request POST 'https://fatture.keliweb.it/api/send-xml-file' \
--header 'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImp0aSI6ImY5Nzk4Y' \
--form 'xml=@"/home/user/Downloads/IT03281320782_00009.xml"'
Example Request (PHP Curl)
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://fatture.keliweb.it/api/send-xml-file',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => array('xml'=> new CURLFILE('/home/user/Downloads/IT03281320782_00009.xml')),
CURLOPT_HTTPHEADER => array(
'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImp0aSI6ImY5Nzk4YTMzODMwMzNmN2I0O'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
Example Request (jQuery AJAX)
var form = new FormData();
form.append("xml", fileInput.files[0], "IT03281320782_00009.xml");
var settings = {
url: "https://fatture.keliweb.it/api/send-xml-file",
method: "POST",
timeout: 0,
headers: {
Authorization:
"Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImp0aSI6ImY5Nzk4YTMzODMwM"
},
processData: false,
mimeType: "multipart/form-data",
contentType: false,
data: form
};
$.ajax(settings).done(function(response) {
console.log(response);
});
Example Request (Python - Requests)
import requests
url = "https://fatture.keliweb.it/api/send-xml-file"
payload={}
files=[
('xml',('IT03281320782_00009.xml',open('/home/user/Downloads/IT03281320782_00009.xml','rb'),'text/xml'))
]
headers = {
'Authorization': 'Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImp0aSI6ImY5Nzk4'
}
response = requests.request("POST", url, headers=headers, data=payload, files=files)
print(response.text)
Example Response (JSON payload)
{
"status": "success",
"message": "Fattura presa in carico dal sistema. SarĂ inviata al prossimo cron giornaliero",
"invoiceData": {
"progressivo": "00002",
"invoiceId": 2,
"filename": "IT03281320782_00002.xml",
"path": "invoices/info@keliweb.it/2022/2",
"version": "FPR12",
"production": false,
"status": "PRESA IN CARICO"
},
"sdi": null
}