Hello here! i’m new here
I’m trying to create a client or an invoice with python helped by chatgpt (I’m a super noob)
I try this code but is not working, I have start the pro version and get the personal token but I got the error after I run my script in the terminal
{“message”:“Invalid Token”,“errors”:{}}
import requests
# Definisci il token e l'URL dell'API di Invoice Ninja
TOKEN = "*********************" # Assicurati di utilizzare il token fornito
API_URL = "https://invoicing.co/api/v1/clients" # Sostituisci "example" con il tuo URL di Invoice Ninja
# Dati del cliente
client_data = {
"name": "Mario Rossi"
}
# Impostazioni dell'intestazione con il token
headers = {
"X-Ninja-Token": TOKEN,
"Content-Type": "application/json",
}
# Effettua la richiesta POST per creare il cliente
response = requests.post(API_URL, json=client_data, headers=headers)
# Controlla lo stato della risposta
if response.status_code == 200:
print("Cliente creato con successo!")
print(response.json()) # Stampa la risposta JSON (opzionale)
else:
print("Si è verificato un errore durante la creazione del cliente:")
print(response.text) # Stampa il testo dell'errore
Who can help me? I can’t find any example file for create something in python, thank you