MasterBalance API

MasterBalance API-documentatie V1

www.masterbalance.nl

⟰   home


Posten van xml


Tekstwaarden die de tekens &, <, of > bevatten, dienen ge-escaped te worden volgens de XML-standaard, anders is de XML ongeldig:

& wordt &amp; < wordt &lt; > wordt &gt; Voorbeeld: "Rente & kosten" wordt "Rente &amp; kosten" in de XML. De meeste programmeertalen bieden hiervoor een ingebouwde functie (bijvoorbeeld htmlspecialchars() in PHP, of een XML-library die dit automatisch afhandelt).

cURL

curl -X POST "https://api.masterbalance.app/v1/[group]/[action]/" \
  -H "Content-Type: application/xml" \
  --data-binary @invoice.xml

of

curl -X POST "https://api.masterbalance.app/v1/[group]/[action]/" \
  -H "Content-Type: application/xml" \
  -d '<?xml version="1.0" encoding="UTF-8"?><document>...</document>'

PHP

$xmlString = '<?xml version="1.0" encoding="UTF-8"?>
<document>
    <contract>
        <apikey>[yourapikey]</apikey>
    </contract>
</document>';

$url = "https://api.masterbalance.app/v1/[group]/[action]/";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, ["Content-Type: application/xml"]);
curl_setopt($ch, CURLOPT_POSTFIELDS, $xmlString);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
$response = curl_exec($ch);
curl_close($ch);
echo $response;

JavaScript

const xmlString = `<?xml version="1.0" encoding="UTF-8"?>
<document>
    <contract>
        <apikey>[yourapikey]</apikey>
    </contract>
</document>`;

fetch("https://api.masterbalance.app/v1/[group]/[action]/", {
    method: "POST",
    headers: {
        "Content-Type": "application/xml"
    },
    body: xmlString
})
    .then(response => response.text())
    .then(data => console.log(data))
    .catch(error => console.error("Error:", error));

Python

import requests

xml_string = '''<?xml version="1.0" encoding="UTF-8"?>
<document>
    <contract>
        <apikey>[yourapikey]</apikey>
    </contract>
</document>'''

url = "https://api.masterbalance.app/v1/[group]/[action]/"
headers = {"Content-Type": "application/xml"}

response = requests.post(url, data=xml_string.encode("utf-8"), headers=headers, timeout=30)
print(response.text)


⟰   home