API: aggiornaAbbinamento

Descrizione

Il metodo aggiornaAbbinamento permette di aggiornare l'abbinamento tra una partita IVA già registrata e una nuova partita IVA per un cliente API.

Va utilizzato se si è precedentemente inviata una partita IVA errata (es: si è inviata la P.Iva "IT1234567890" anziché "IT12345678901").

Parametri

  • clienti (obbligatorio): Una lista di oggetti con la partita IVA errata (old) e la nuova partita IVA corretta (new) da abbinare.

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": "aggiornaAbbinamento",
        "input": {
            "clienti": [
                {
                    "old": "06363391001",
                    "new": "06363391002"
                }
            ]
        }
    }
}

Esempi di Codice



$url = 'https://www.fattureweb.com/api/';
$data = array(
    'action' => 'call',
    'key' => '95415ceca602e867e573f65a50c9b70bd6906828',
    'code' => 'abcdef',
    'payload' => array(
        'api_name' => 'Configurazione',
        'method' => 'aggiornaAbbinamento',
        'input' => array(
            'clienti' => array(
                array('old' => '06363391001', 'new' => '06363391002')
            )
        )
    )
);
$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': 'aggiornaAbbinamento',
        'input': {
            'clienti':  [{'old': '06363391001', 'new': '06363391002'}]
        }
    }
}

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\": \"aggiornaAbbinamento\", \"input\": {\"clienti\": [{\"old\": \"06363391001\", \"new\": \"06363391002\"}]}}}";
            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 aggiornati correttamente"
}

Risposta di Errore

Se si verifica un errore, riceverai una risposta come questa:

{
    "status": "error",
    "message": "Errore: La P.Iva 06363391001 NON risulta abbinata al tuo account"
}