In order to initiate an order submission, it is necessary to invoke our API while providing print instructions in JSON format and including a hyperlink to the associated PDF file.
It is important to note that immediate feedback regarding the order's content is not provided at the time of submission.
The response solely confirms the receipt of the POST request.
Subsequently, the order proceeds to the processing stage, during which any encountered issues are communicated through subsequent messages.
$orderData = file_get_contents("sampleorder.json");
$headers = array(
"Accept: application/json",
"Authorization: Bearer YOURTOKEN",
);
$ch = curl_init('https://coberapi.com/api/1.0/order');
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($orderData));
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
const https = require('https');
const fs = require('fs');
const orderData = fs.readFileSync('sampleorder.json', 'utf8');
const headers = {
'Accept': 'application/json',
'Authorization': 'Bearer YOURTOKEN'
};
const options = {
hostname: 'coberapi.com',
path: '/api/1.0/order',
method: 'POST',
headers: headers
};
const req = https.request(options, (res) => {
let responseData = '';
res.on('data', (chunk) => {
responseData += chunk;
});
res.on('end', () => {
console.log(responseData);
});
});
req.write(orderData);
req.end();
using System;
using System.IO;
using System.Net;
using System.Text;
class Program
{
static void Main()
{
string url = "https://coberapi.com/api/1.0/order";
string token = "YOURTOKEN";
byte[] orderData = File.ReadAllBytes("sampleorder.json");
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
request.Method = "POST";
request.ContentType = "application/json";
request.Headers.Add("Authorization", "Bearer " + token);
using (Stream requestStream = request.GetRequestStream())
{
requestStream.Write(orderData, 0, orderData.Length);
}
using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
using (Stream responseStream = response.GetResponseStream())
using (StreamReader reader = new StreamReader(responseStream))
{
string responseData = reader.ReadToEnd();
Console.WriteLine(responseData);
}
}
}
import java.io.IOException;
import java.io.OutputStream;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.net.HttpURLConnection;
import java.net.URL;
import java.nio.charset.StandardCharsets;
public class Main {
public static void main(String[] args) throws IOException {
String url = "https://coberapi.com/api/1.0/order";
String token = "YOURTOKEN";
byte[] orderData = Files.readAllBytes(Paths.get("sampleorder.json"));
URL urlObject = new URL(url);
HttpURLConnection connection = (HttpURLConnection) urlObject.openConnection();
connection.setRequestMethod("POST");
connection.setDoOutput(true);
connection.setRequestProperty("Content-Type", "application/json");
connection.setRequestProperty("Authorization", "Bearer " + token);
try (OutputStream os = connection.getOutputStream()) {
os.write(orderData, 0, orderData.length);
}
int responseCode = connection.getResponseCode();
if (responseCode == HttpURLConnection.HTTP_OK) {
java.io.BufferedReader in = new java.io.BufferedReader(new java.io.InputStreamReader(connection.getInputStream()));
String inputLine;
StringBuffer response = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
in.close();
System.out.println(response.toString());
} else {
System.out.println("HTTP request failed with response code: " + responseCode);
}
}
}