curl -X POST "https://trackservice.trackroad.com/rest/geocode" \
-H "Content-Type: application/json" \
-H "X-API-Key: YOUR_TRACKSERVICEKEY" \
-d '{
"IsNeedMatchCode": true,
"Addresses": [
{ "Street": "6718 Whittier Avenue", "City": "McLean", "State": "VA", "PostalCode": "22101", "Country": "US" }
]
}'
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
var url = "https://trackservice.trackroad.com/rest/geocode";
using var http = new HttpClient();
http.DefaultRequestHeaders.Add("X-API-Key", "YOUR_TRACKSERVICEKEY");
var json = @"{
""IsNeedMatchCode"": true,
""Addresses"": [
{ ""Street"": ""6718 Whittier Avenue"", ""City"": ""McLean"", ""State"": ""VA"", ""PostalCode"": ""22101"", ""Country"": ""US"" }
]
}";
using var content = new StringContent(json, Encoding.UTF8, "application/json");
var resp = await http.PostAsync(url, content);
Console.WriteLine(await resp.Content.ReadAsStringAsync());
const url = "https://trackservice.trackroad.com/rest/geocode";
const payload = {
IsNeedMatchCode: true,
Addresses: [
{ Street: "6718 Whittier Avenue", City: "McLean", State: "VA", PostalCode: "22101", Country: "US" }
]
};
const res = await fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/json",
"X-API-Key": "YOUR_TRACKSERVICEKEY"
},
body: JSON.stringify(payload)
});
console.log(await res.text());
import okhttp3.*;
public class Main {
public static void main(String[] args) throws Exception {
OkHttpClient client = new OkHttpClient();
String json = "{"
+ "\"IsNeedMatchCode\":true,"
+ "\"Addresses\":[{"
+ "\"Street\":\"6718 Whittier Avenue\","
+ "\"City\":\"McLean\","
+ "\"State\":\"VA\","
+ "\"PostalCode\":\"22101\","
+ "\"Country\":\"US\""
+ "}]"
+ "}";
RequestBody body = RequestBody.create(json, MediaType.parse("application/json"));
Request request = new Request.Builder()
.url("https://trackservice.trackroad.com/rest/geocode")
.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/geocode"
headers = {
"Content-Type": "application/json",
"X-API-Key": "YOUR_TRACKSERVICEKEY"
}
payload = {
"IsNeedMatchCode": True,
"Addresses": [
{ "Street": "6718 Whittier Avenue", "City": "McLean", "State": "VA", "PostalCode": "22101", "Country": "US" }
]
}
r = requests.post(url, headers=headers, json=payload)
print(r.text)
<?php
$url = "https://trackservice.trackroad.com/rest/geocode";
$payload = json_encode([
"IsNeedMatchCode" => true,
"Addresses" => [[
"Street" => "6718 Whittier Avenue",
"City" => "McLean",
"State" => "VA",
"PostalCode" => "22101",
"Country" => "US"
]]
]);
$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 => $payload
]);
echo curl_exec($ch);
curl_close($ch);
require "net/http"
require "json"
uri = URI("https://trackservice.trackroad.com/rest/geocode")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
payload = {
IsNeedMatchCode: true,
Addresses: [
{ Street: "6718 Whittier Avenue", City: "McLean", State: "VA", PostalCode: "22101", Country: "US" }
]
}
req = Net::HTTP::Post.new(uri)
req["Content-Type"] = "application/json"
req["X-API-Key"] = "YOUR_TRACKSERVICEKEY"
req.body = payload.to_json
res = http.request(req)
puts res.body
package main
import (
"bytes"
"fmt"
"io"
"net/http"
)
func main() {
url := "https://trackservice.trackroad.com/rest/geocode"
jsonBody := []byte(`{
"IsNeedMatchCode": true,
"Addresses": [
{ "Street": "6718 Whittier Avenue", "City": "McLean", "State": "VA", "PostalCode": "22101", "Country": "US" }
]
}`)
req, _ := http.NewRequest("POST", url, bytes.NewBuffer(jsonBody))
req.Header.Set("Content-Type", "application/json")
req.Header.Set("X-API-Key", "YOUR_TRACKSERVICEKEY")
resp, err := http.DefaultClient.Do(req)
if err != nil { panic(err) }
defer resp.Body.Close()
b, _ := io.ReadAll(resp.Body)
fmt.Println(string(b))
}
import java.net.URI
import java.net.http.HttpClient
import java.net.http.HttpRequest
import java.net.http.HttpResponse
fun main() {
val url = "https://trackservice.trackroad.com/rest/geocode"
val json = """
{
"IsNeedMatchCode": true,
"Addresses": [
{ "Street": "6718 Whittier Avenue", "City": "McLean", "State": "VA", "PostalCode": "22101", "Country": "US" }
]
}
""".trimIndent()
val client = HttpClient.newHttpClient()
val req = HttpRequest.newBuilder()
.uri(URI.create(url))
.header("Content-Type", "application/json")
.header("X-API-Key", "YOUR_TRACKSERVICEKEY")
.POST(HttpRequest.BodyPublishers.ofString(json))
.build()
val resp = client.send(req, HttpResponse.BodyHandlers.ofString())
println(resp.body())
}
#include <stdio.h>
#include <curl/curl.h>
int main(void) {
CURL *curl = curl_easy_init();
if(!curl) return 1;
const char *url = "https://trackservice.trackroad.com/rest/geocode";
const char *json =
"{"
"\"IsNeedMatchCode\":true,"
"\"Addresses\":[{"
"\"Street\":\"6718 Whittier Avenue\","
"\"City\":\"McLean\","
"\"State\":\"VA\","
"\"PostalCode\":\"22101\","
"\"Country\":\"US\""
"}]"
"}";
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, url);
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, json);
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>
#include <string>
int main() {
CURL* curl = curl_easy_init();
if(!curl) return 1;
std::string url = "https://trackservice.trackroad.com/rest/geocode";
std::string json =
"{"
"\"IsNeedMatchCode\":true,"
"\"Addresses\":[{"
"\"Street\":\"6718 Whittier Avenue\","
"\"City\":\"McLean\","
"\"State\":\"VA\","
"\"PostalCode\":\"22101\","
"\"Country\":\"US\""
"}]"
"}";
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, url.c_str());
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, json.c_str());
CURLcode res = curl_easy_perform(curl);
curl_slist_free_all(headers);
curl_easy_cleanup(curl);
return (res == CURLE_OK) ? 0 : 1;
}
#import <Foundation/Foundation.h>
int main() {
@autoreleasepool {
NSURL *url = [NSURL URLWithString:@"https://trackservice.trackroad.com/rest/geocode"];
NSMutableURLRequest *req = [NSMutableURLRequest requestWithURL:url];
[req setHTTPMethod:@"POST"];
[req setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
[req setValue:@"YOUR_TRACKSERVICEKEY" forHTTPHeaderField:@"X-API-Key"];
NSDictionary *payload = @{
@"IsNeedMatchCode": @YES,
@"Addresses": @[
@{
@"Street": @"6718 Whittier Avenue",
@"City": @"McLean",
@"State": @"VA",
@"PostalCode": @"22101",
@"Country": @"US"
}
]
};
NSData *body = [NSJSONSerialization dataWithJSONObject:payload options:0 error:nil];
[req setHTTPBody:body];
NSURLSessionDataTask *task =
[[NSURLSession sharedSession] dataTaskWithRequest:req
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) { NSLog(@"%@", error); return; }
NSString *text = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
NSLog(@"%@", text);
}];
[task resume];
[[NSRunLoop currentRunLoop] run];
}
return 0;
}
import Foundation
let url = URL(string: "https://trackservice.trackroad.com/rest/geocode")!
var req = URLRequest(url: url)
req.httpMethod = "POST"
req.setValue("application/json", forHTTPHeaderField: "Content-Type")
req.setValue("YOUR_TRACKSERVICEKEY", forHTTPHeaderField: "X-API-Key")
let payload: [String: Any] = [
"IsNeedMatchCode": true,
"Addresses": [
[
"Street": "6718 Whittier Avenue",
"City": "McLean",
"State": "VA",
"PostalCode": "22101",
"Country": "US"
]
]
]
req.httpBody = try! JSONSerialization.data(withJSONObject: payload)
let task = URLSession.shared.dataTask(with: req) { data, _, error in
if let error = error { print(error); return }
print(String(data: data ?? Data(), encoding: .utf8) ?? "")
}
task.resume()
RunLoop.main.run()