API: abbinaPiva
Descrizione
Il metodo abbinaPiva
permette di abbinare una lista di partite IVA di clienti a un utente API. Questa API è specificamente rivolta agli Utenti API di tipo Intermediario.
Parametri
- clienti (obbligatorio): Una lista di partite IVA dei clienti da abbinare all'Utente API Intermediario.
Chiamata API
La chiamata deve essere effettuata tramite POST all'endpoint:
https://www.fattureweb.com/api/
Esempio di Chiamata POST
{
"action":"call",
"key": "95415ceca602e867e573f65a50c9b70bd6906828",
"code": "abcdef",
"payload": {
"api_name": "Configurazione",
"method": "salvaAbbinamento",
"input": {
"clienti": [
"06363391001",
"IT06157670966",
"IT00979730090"
]
}
}
}
Esempi di Codice
$url = 'https://www.fattureweb.com/api/';
$data = array(
'action' => 'call',
'key' => '95415ceca602e867e573f65a50c9b70bd6906828',
'code' => 'abcdef',
'payload' => json_encode(array(
'api_name' => 'Configurazione',
'method' => 'salvaAbbinamento',
'input' => array(
'clienti' => array(
'06363391001',
'IT06157670966',
'IT00979730090'
)
)
))
);
$options = array(
'http' => array(
'header' => "Content-Type: application/json\r\n",
'method' => 'POST',
'content' => json_encode($data),
),
);
$context = stream_context_create($options);
$result = file_get_contents($url, false, $context);
if ($result === FALSE) { /* Handle error */ }
var_dump($result);
import requests
url = 'https://www.fattureweb.com/api/'
data = {
"action": "call",
"key": "95415ceca602e867e573f65a50c9b70bd6906828",
"code": "abcdef",
"payload": {
"api_name": "Configurazione",
"method": "salvaAbbinamento",
"input": {
"clienti": [
"06363391001",
"IT06157670966",
"IT00979730090"
]
}
}
}
response = requests.post(url, json=data)
print(response.text)
import java.net.HttpURLConnection;
import java.net.URL;
import java.io.OutputStream;
public class Main {
public static void main(String[] args) {
try {
URL url = new URL("https://www.fattureweb.com/api/");
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("POST");
conn.setRequestProperty("Content-Type", "application/json; utf-8");
conn.setDoOutput(true);
String jsonInputString = "{\"action\": \"call\",\"key\": \"95415ceca602e867e573f65a50c9b70bd6906828\", \"code\": \"abcdef\", \"payload\": {\"api_name\": \"Configurazione\", \"method\": \"salvaAbbinamento\", \"input\": {\"clienti\": [\"06363391001\", \"IT06157670966\", \"IT00979730090\"]}}}";
try (OutputStream os = conn.getOutputStream()) {
byte[] input = jsonInputString.getBytes("utf-8");
os.write(input, 0, input.length);
}
int responseCode = conn.getResponseCode();
System.out.println("Response Code: " + responseCode);
} catch (Exception e) {
e.printStackTrace();
}
}
}
Risposta di Successo
Se la chiamata ha successo, riceverai una risposta come la seguente:
{
"status": "success",
"message": "Clienti registrati correttamente"
}
Risposta di Errore
Se si verifica un errore, riceverai una risposta come questa:
{
"status": "error",
"message": "Errore: La P.Iva 06363391001 risulta abbinata a un altro Cliente"
}