curl -X POST https://simplewebapis.com/api/purchaseorder \
-H "Content-Type: application/json" \
-H "X-Api-Key: swa_your_key" \
-d '{
"orderNumber": 1001,
"buyer": { "name": "Acme Corp", "addressLines": ["123 Buyer St", "San Francisco, CA 94105"], "email": "[email protected]" },
"vendor": { "name": "Globex Inc", "addressLines": ["456 Vendor Ave", "New York, NY 10001"], "email": "[email protected]" },
"shippingAddress": { "name": "Acme Corp", "addressLines": ["123 Buyer St", "San Francisco, CA 94105"] },
"items": [
{ "name": "Office Chairs", "price": 450.00, "quantity": 10 },
{ "name": "Standing Desks", "price": 800.00, "quantity": 5 }
],
"taxRate": 0.08,
"notes": "Please deliver to the loading dock on the east side.",
"currency": "USD",
"logoUrl": "https://simplewebapis.com/favicon-32x32.png",
"accentColor": "#2563EB",
"separatorColor": "#E5E7EB",
"notesBackgroundColor": "#F9FAFB"
}' --output purchase-order.pdf
using var client = new HttpClient();
client.DefaultRequestHeaders.Add("X-Api-Key", "swa_your_key");
var payload = new
{
orderNumber = 1001,
buyer = new { name = "Acme Corp", addressLines = new[] { "123 Buyer St", "San Francisco, CA 94105" }, email = "[email protected]" },
vendor = new { name = "Globex Inc", addressLines = new[] { "456 Vendor Ave", "New York, NY 10001" }, email = "[email protected]" },
shippingAddress = new { name = "Acme Corp", addressLines = new[] { "123 Buyer St", "San Francisco, CA 94105" } },
items = new[]
{
new { name = "Office Chairs", price = 450.00m, quantity = 10 },
new { name = "Standing Desks", price = 800.00m, quantity = 5 }
},
taxRate = 0.08m,
notes = "Please deliver to the loading dock on the east side.",
Currency = "USD",
LogoUrl = "https://simplewebapis.com/favicon-32x32.png",
accentColor = "#2563EB",
separatorColor = "#E5E7EB",
notesBackgroundColor = "#F9FAFB"
};
var json = JsonSerializer.Serialize(payload);
var content = new StringContent(json, Encoding.UTF8, "application/json");
var response = await client.PostAsync(
"https://simplewebapis.com/api/purchaseorder", content);
var pdfBytes = await response.Content.ReadAsByteArrayAsync();
await File.WriteAllBytesAsync("purchase-order.pdf", pdfBytes);
$payload = json_encode([
'orderNumber' => 1001,
'buyer' => ['name' => 'Acme Corp', 'addressLines' => ['123 Buyer St', 'San Francisco, CA 94105'], 'email' => '[email protected]'],
'vendor' => ['name' => 'Globex Inc', 'addressLines' => ['456 Vendor Ave', 'New York, NY 10001'], 'email' => '[email protected]'],
'shippingAddress' => ['name' => 'Acme Corp', 'addressLines' => ['123 Buyer St', 'San Francisco, CA 94105']],
'items' => [
['name' => 'Office Chairs', 'price' => 450.00, 'quantity' => 10],
['name' => 'Standing Desks', 'price' => 800.00, 'quantity' => 5],
],
'taxRate' => 0.08,
'notes' => 'Please deliver to the loading dock on the east side.',
'currency' => 'USD',
'logoUrl' => 'https://simplewebapis.com/favicon-32x32.png',
'accentColor' => '#2563EB',
'separatorColor' => '#E5E7EB',
'notesBackgroundColor' => '#F9FAFB',
]);
$ch = curl_init('https://simplewebapis.com/api/purchaseorder');
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_HTTPHEADER => [
'Content-Type: application/json',
'X-Api-Key: swa_your_key',
],
CURLOPT_POSTFIELDS => $payload,
CURLOPT_RETURNTRANSFER => true,
]);
$pdf = curl_exec($ch);
curl_close($ch);
file_put_contents('purchase-order.pdf', $pdf);
const response = await fetch('https://simplewebapis.com/api/purchaseorder', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-Api-Key': 'swa_your_key',
},
body: JSON.stringify({
orderNumber: 1001,
buyer: { name: 'Acme Corp', addressLines: ['123 Buyer St', 'San Francisco, CA 94105'], email: '[email protected]' },
vendor: { name: 'Globex Inc', addressLines: ['456 Vendor Ave', 'New York, NY 10001'], email: '[email protected]' },
shippingAddress: { name: 'Acme Corp', addressLines: ['123 Buyer St', 'San Francisco, CA 94105'] },
items: [
{ name: 'Office Chairs', price: 450.00, quantity: 10 },
{ name: 'Standing Desks', price: 800.00, quantity: 5 },
],
taxRate: 0.08,
notes: 'Please deliver to the loading dock on the east side.',
currency: 'USD',
logoUrl: 'https://simplewebapis.com/favicon-32x32.png',
accentColor: '#2563EB',
separatorColor: '#E5E7EB',
notesBackgroundColor: '#F9FAFB',
}),
});
const buffer = await response.arrayBuffer();
const fs = require('fs');
fs.writeFileSync('purchase-order.pdf', Buffer.from(buffer));
import requests
response = requests.post(
'https://simplewebapis.com/api/purchaseorder',
headers={
'Content-Type': 'application/json',
'X-Api-Key': 'swa_your_key',
},
json={
'orderNumber': 1001,
'buyer': {'name': 'Acme Corp', 'addressLines': ['123 Buyer St', 'San Francisco, CA 94105'], 'email': '[email protected]'},
'vendor': {'name': 'Globex Inc', 'addressLines': ['456 Vendor Ave', 'New York, NY 10001'], 'email': '[email protected]'},
'shippingAddress': {'name': 'Acme Corp', 'addressLines': ['123 Buyer St', 'San Francisco, CA 94105']},
'items': [
{'name': 'Office Chairs', 'price': 450.00, 'quantity': 10},
{'name': 'Standing Desks', 'price': 800.00, 'quantity': 5},
],
'taxRate': 0.08,
'notes': 'Please deliver to the loading dock on the east side.',
'currency': 'USD',
'logoUrl': 'https://simplewebapis.com/favicon-32x32.png',
'accentColor': '#2563EB',
'separatorColor': '#E5E7EB',
'notesBackgroundColor': '#F9FAFB',
},
)
with open('purchase-order.pdf', 'wb') as f:
f.write(response.content)
payload := map[string]interface{}{
"orderNumber": 1001,
"buyer": map[string]interface{}{
"name": "Acme Corp",
"addressLines": []string{"123 Buyer St", "San Francisco, CA 94105"},
"email": "[email protected]",
},
"vendor": map[string]interface{}{
"name": "Globex Inc",
"addressLines": []string{"456 Vendor Ave", "New York, NY 10001"},
"email": "[email protected]",
},
"shippingAddress": map[string]interface{}{
"name": "Acme Corp",
"addressLines": []string{"123 Buyer St", "San Francisco, CA 94105"},
},
"items": []map[string]interface{}{
{"name": "Office Chairs", "price": 450.00, "quantity": 10},
{"name": "Standing Desks", "price": 800.00, "quantity": 5},
},
"taxRate": 0.08,
"notes": "Please deliver to the loading dock on the east side.",
"currency": "USD",
"logoUrl": "https://simplewebapis.com/favicon-32x32.png",
"accentColor": "#2563EB",
"separatorColor": "#E5E7EB",
"notesBackgroundColor": "#F9FAFB",
}
jsonData, _ := json.Marshal(payload)
req, _ := http.NewRequest("POST", "https://simplewebapis.com/api/purchaseorder",
bytes.NewBuffer(jsonData))
req.Header.Set("Content-Type", "application/json")
req.Header.Set("X-Api-Key", "swa_your_key")
resp, _ := http.DefaultClient.Do(req)
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
os.WriteFile("purchase-order.pdf", body, 0644)
require 'net/http'
require 'json'
require 'uri'
payload = {
orderNumber: 1001,
buyer: { name: 'Acme Corp', addressLines: ['123 Buyer St', 'San Francisco, CA 94105'], email: '[email protected]' },
vendor: { name: 'Globex Inc', addressLines: ['456 Vendor Ave', 'New York, NY 10001'], email: '[email protected]' },
shippingAddress: { name: 'Acme Corp', addressLines: ['123 Buyer St', 'San Francisco, CA 94105'] },
items: [
{ name: 'Office Chairs', price: 450.00, quantity: 10 },
{ name: 'Standing Desks', price: 800.00, quantity: 5 },
],
taxRate: 0.08,
notes: 'Please deliver to the loading dock on the east side.',
currency: 'USD',
logo_url: 'https://simplewebapis.com/favicon-32x32.png',
accentColor: '#2563EB',
separatorColor: '#E5E7EB',
notesBackgroundColor: '#F9FAFB',
}
uri = URI('https://simplewebapis.com/api/purchaseorder')
req = Net::HTTP::Post.new(uri)
req['Content-Type'] = 'application/json'
req['X-Api-Key'] = 'swa_your_key'
req.body = payload.to_json
response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) { |http| http.request(req) }
File.binwrite('purchase-order.pdf', response.body)
var payload = """
{
"orderNumber": 1001,
"buyer": { "name": "Acme Corp", "addressLines": ["123 Buyer St", "San Francisco, CA 94105"], "email": "[email protected]" },
"vendor": { "name": "Globex Inc", "addressLines": ["456 Vendor Ave", "New York, NY 10001"], "email": "[email protected]" },
"shippingAddress": { "name": "Acme Corp", "addressLines": ["123 Buyer St", "San Francisco, CA 94105"] },
"items": [
{ "name": "Office Chairs", "price": 450.00, "quantity": 10 },
{ "name": "Standing Desks", "price": 800.00, "quantity": 5 }
],
"taxRate": 0.08,
"notes": "Please deliver to the loading dock on the east side.",
"currency": "USD",
"logoUrl": "https://simplewebapis.com/favicon-32x32.png",
"accentColor": "#2563EB",
"separatorColor": "#E5E7EB",
"notesBackgroundColor": "#F9FAFB"
}
""";
var request = HttpRequest.newBuilder()
.uri(URI.create("https://simplewebapis.com/api/purchaseorder"))
.header("Content-Type", "application/json")
.header("X-Api-Key", "swa_your_key")
.POST(HttpRequest.BodyPublishers.ofString(payload))
.build();
var response = HttpClient.newHttpClient().send(request,
HttpResponse.BodyHandlers.ofByteArray());
Files.write(Path.of("purchase-order.pdf"), response.body());
use serde_json::json;
use std::fs;
let client = reqwest::Client::new();
let payload = json!({
"orderNumber": 1001,
"buyer": { "name": "Acme Corp", "addressLines": ["123 Buyer St", "San Francisco, CA 94105"], "email": "[email protected]" },
"vendor": { "name": "Globex Inc", "addressLines": ["456 Vendor Ave", "New York, NY 10001"], "email": "[email protected]" },
"shippingAddress": { "name": "Acme Corp", "addressLines": ["123 Buyer St", "San Francisco, CA 94105"] },
"items": [
{ "name": "Office Chairs", "price": 450.00, "quantity": 10 },
{ "name": "Standing Desks", "price": 800.00, "quantity": 5 }
],
"taxRate": 0.08,
"notes": "Please deliver to the loading dock on the east side.",
"currency": "USD",
"logoUrl": "https://simplewebapis.com/favicon-32x32.png",
"accentColor": "#2563EB",
"separatorColor": "#E5E7EB",
"notesBackgroundColor": "#F9FAFB"
});
let resp = client.post("https://simplewebapis.com/api/purchaseorder")
.header("Content-Type", "application/json")
.header("X-Api-Key", "swa_your_key")
.json(&payload)
.send()
.await?;
let bytes = resp.bytes().await?;
fs::write("purchase-order.pdf", &bytes)?;