$data = ['orderIDs' => ['order1', 'order2']];
$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_CUSTOMREQUEST, "PUT");
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
$responseCode = curl_getinfo($ch, CURLINFO_RESPONSE_CODE);
curl_close($ch);
const https = require('https');
const data = {
orderIDs: ['order1', 'order2']
};
const headers = {
'Accept': 'application/json',
'Authorization': 'Bearer YOURTOKEN'
};
const options = {
hostname: 'coberapi.com',
path: '/api/1.0/order',
method: 'PUT',
headers: headers
};
const req = https.request(options, (res) => {
let responseData = '';
res.on('data', (chunk) => {
responseData += chunk;
});
res.on('end', () => {
console.log(responseData);
});
});
req.write(JSON.stringify(data));
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";
string data = "{\"orderIDs\":[\"order1\",\"order2\"]}";
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
request.Method = "PUT";
request.ContentType = "application/json";
request.Headers.Add("Authorization", "Bearer " + token);
using (StreamWriter writer = new StreamWriter(request.GetRequestStream()))
{
writer.Write(data);
}
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.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";
String data = "{\"orderIDs\":[\"order1\",\"order2\"]}";
URL urlObject = new URL(url);
HttpURLConnection connection = (HttpURLConnection) urlObject.openConnection();
connection.setRequestMethod("PUT");
connection.setDoOutput(true);
connection.setRequestProperty("Content-Type", "application/json");
connection.setRequestProperty("Authorization", "Bearer " + token);
try (OutputStream os = connection.getOutputStream()) {
byte[] input = data.getBytes(StandardCharsets.UTF_8);
os.write(input, 0, input.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);
}
}
}