curl -X POST "https://trackservice.trackroad.com/rest/dispatch" \
-H "Content-Type: application/json" \
-H "X-API-Key: YOUR_TRACKSERVICEKEY" \
-d '{ }'
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
var url = "https://trackservice.trackroad.com/rest/dispatch";
using var http = new HttpClient();
http.DefaultRequestHeaders.Add("X-API-Key", "YOUR_TRACKSERVICEKEY");
var json = "{ }";
using var content = new StringContent(json, Encoding.UTF8, "application/json");
var resp = await http.PostAsync(url, content);
var body = await resp.Content.ReadAsStringAsync();
Console.WriteLine(body);
const url = "https://trackservice.trackroad.com/rest/dispatch";
const res = await fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/json",
"X-API-Key": "YOUR_TRACKSERVICEKEY"
},
body: JSON.stringify({})
});
console.log(await res.text());
import okhttp3.*;
public class Main {
public static void main(String[] args) throws Exception {
OkHttpClient client = new OkHttpClient();
RequestBody body = RequestBody.create("{}", MediaType.parse("application/json"));
Request request = new Request.Builder()
.url("https://trackservice.trackroad.com/rest/dispatch")
.post(body)
.addHeader("Content-Type", "application/json")
.addHeader("X-API-Key", "YOUR_TRACKSERVICEKEY")
.build();
try (Response response = client.newCall(request).execute()) {
System.out.println(response.body().string());
}
}
}
import requests
url = "https://trackservice.trackroad.com/rest/dispatch"
headers = {
"Content-Type": "application/json",
"X-API-Key": "YOUR_TRACKSERVICEKEY"
}
r = requests.post(url, headers=headers, json={})
print(r.text)
<?php
$url = "https://trackservice.trackroad.com/rest/dispatch";
$ch = curl_init($url);
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-API-Key: YOUR_TRACKSERVICEKEY"
],
CURLOPT_POSTFIELDS => "{}"
]);
$response = curl_exec($ch);
curl_close($ch);
echo $response;
require "net/http"
require "uri"
require "json"
uri = URI.parse("https://trackservice.trackroad.com/rest/dispatch")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
req = Net::HTTP::Post.new(uri.request_uri)
req["Content-Type"] = "application/json"
req["X-API-Key"] = "YOUR_TRACKSERVICEKEY"
req.body = {}.to_json
res = http.request(req)
puts res.body
package main
import (
"bytes"
"fmt"
"net/http"
"io"
)
func main() {
url := "https://trackservice.trackroad.com/rest/dispatch"
payload := []byte(`{}`)
req, _ := http.NewRequest("POST", url, bytes.NewBuffer(payload))
req.Header.Set("Content-Type", "application/json")
req.Header.Set("X-API-Key", "YOUR_TRACKSERVICEKEY")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil { panic(err) }
defer resp.Body.Close()
b, _ := io.ReadAll(resp.Body)
fmt.Println(string(b))
}
import okhttp3.MediaType.Companion.toMediaType
import okhttp3.OkHttpClient
import okhttp3.Request
import okhttp3.RequestBody.Companion.toRequestBody
fun main() {
val client = OkHttpClient()
val mediaType = "application/json".toMediaType()
val body = "{}".toRequestBody(mediaType)
val request = Request.Builder()
.url("https://trackservice.trackroad.com/rest/dispatch")
.post(body)
.addHeader("Content-Type", "application/json")
.addHeader("X-API-Key", "YOUR_TRACKSERVICEKEY")
.build()
client.newCall(request).execute().use { response ->
println(response.body?.string())
}
}
#include <stdio.h>
#include <curl/curl.h>
int main(void) {
CURL *curl = curl_easy_init();
if (!curl) return 1;
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "Content-Type: application/json");
headers = curl_slist_append(headers, "X-API-Key: YOUR_TRACKSERVICEKEY");
curl_easy_setopt(curl, CURLOPT_URL, "https://trackservice.trackroad.com/rest/dispatch");
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, "{}");
CURLcode res = curl_easy_perform(curl);
curl_slist_free_all(headers);
curl_easy_cleanup(curl);
return (res == CURLE_OK) ? 0 : 1;
}
#include <curl/curl.h>
int main() {
CURL* curl = curl_easy_init();
if (!curl) return 1;
struct curl_slist* headers = nullptr;
headers = curl_slist_append(headers, "Content-Type: application/json");
headers = curl_slist_append(headers, "X-API-Key: YOUR_TRACKSERVICEKEY");
curl_easy_setopt(curl, CURLOPT_URL, "https://trackservice.trackroad.com/rest/dispatch");
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, "{}");
CURLcode res = curl_easy_perform(curl);
curl_slist_free_all(headers);
curl_easy_cleanup(curl);
return (res == CURLE_OK) ? 0 : 1;
}
@import Foundation;
int main() {
@autoreleasepool {
NSURL *url = [NSURL URLWithString:@"https://trackservice.trackroad.com/rest/dispatch"];
NSMutableURLRequest *req = [NSMutableURLRequest requestWithURL:url];
req.HTTPMethod = @"POST";
[req setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
[req setValue:@"YOUR_TRACKSERVICEKEY" forHTTPHeaderField:@"X-API-Key"];
req.HTTPBody = [@"{}" dataUsingEncoding:NSUTF8StringEncoding];
dispatch_semaphore_t sema = dispatch_semaphore_create(0);
NSURLSessionDataTask *task =
[[NSURLSession sharedSession] dataTaskWithRequest:req
completionHandler:^(NSData *data, NSURLResponse *resp, NSError *err) {
if (data) {
NSString *s = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
NSLog(@"%@", s);
}
dispatch_semaphore_signal(sema);
}];
[task resume];
dispatch_semaphore_wait(sema, DISPATCH_TIME_FOREVER);
}
return 0;
}
import Foundation
let url = URL(string: "https://trackservice.trackroad.com/rest/dispatch")!
var req = URLRequest(url: url)
req.httpMethod = "POST"
req.setValue("application/json", forHTTPHeaderField: "Content-Type")
req.setValue("YOUR_TRACKSERVICEKEY", forHTTPHeaderField: "X-API-Key")
req.httpBody = "{}".data(using: .utf8)
let task = URLSession.shared.dataTask(with: req) { data, _, error in
if let data = data {
print(String(data: data, encoding: .utf8) ?? "")
} else if let error = error {
print(error)
}
}
task.resume()