var request = require("request");
var options = {
method: "POST",
url: "https://api.jetapi.io/api/v1/delivery",
headers: { authorization: "Bearer yourtoken123456", "content-type": "application/json" },
body: { text: "hello world", phone: "15551234567" },
json: true,
};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
import fetch from 'node-fetch';
const url = 'https://api.jetapi.io/api/v1/delivery';
const body = { text: 'hello world', phone: '15551234567' };
const headers = {
authorization: 'Bearer yourtoken123456',
'content-type': 'application/json',
};
const response = await fetch(url, {
method: 'post',
body: JSON.stringify(body),
headers: headers,
});
const data = await response.json();
console.log(data);
import http.client
conn = http.client.HTTPSConnection("api.jetapi.io")
payload = "{\"text\":\"hello world\",\"phone\":\"15551234567\"}"
headers = { 'authorization': "Bearer yourtoken123456",
'content-type': 'application/json'
}
conn.request("POST", "/api/v1/delivery", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
import requests
url = "https://api.jetapi.io/api/v1/delivery"
payload = "{\"text\":\"hello world\",\"phone\":\"15551234567\"}"
headers = {
'authorization': 'Bearer yourtoken123456',
'content-type': 'application/json'
}
response = requests.request("POST", url, data = payload, headers = headers)
print(response.text)
import kong.unirest.HttpResponse;
import kong.unirest.JsonNode;
import kong.unirest.Unirest;
// .....
HttpResponse<JsonNode> response = Unirest.post("https://api.jetapi.io/api/v1/delivery")
.header("Content-Type", "application/json")
.header("Authorization", "Bearer yourtoken123456")
.body("{\"text\":\"hello world\",\"phone\":\"15551234567\"}")
.asJson();
System.out.println(response.getBody());
import java.io.IOException;
import okhttp3.MediaType;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response;
// .....
String data = "{\"text\":\"hello world\",\"phone\":\"15551234567\"}";
MediaType jsonMediaType = MediaType.get("application/json; charset=utf-8");
RequestBody body = RequestBody.create(data, jsonMediaType);
String url = "https://api.jetapi.io/api/v1/delivery";
String accessToken = "yourtoken123456";
Request request = new Request.Builder()
.url(url)
.post(body)
.addHeader("authorization", "Bearer " + accessToken)
.build();
OkHttpClient client = new OkHttpClient();
try (Response response = client.newCall(request).execute()) {
System.out.println(response.body().string());
} catch (IOException e) {
e.printStackTrace();
}
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.jetapi.io/api/v1/delivery",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "{\"text\":\"hello world\",\"phone\":\"15551234567\"}",
CURLOPT_HTTPHEADER => array(
"authorization: Bearer yourtoken123456",
"content-type: application/json"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
using System;
using RestSharp;
using System.Threading;
using RestSharp.Authenticators.OAuth2;
// .....
var access_token = "yourtoken123456";
var client = new RestClient("api.jetapi.io/api/v1/");
client.Authenticator = new OAuth2AuthorizationRequestHeaderAuthenticator(access_token, "Bearer");
var request_params = new
{
text = "hello world",
phone = "15551234567"
};
var request = new RestRequest("delivery").AddJsonBody(request_params);
try
{
var response = await client.PostAsync(request);
Console.WriteLine(response.Content);
}
catch(Exception e) {
Console.WriteLine("{0} Exception caught.", e);
require 'uri'
require 'net/http'
require 'openssl'
require 'json'
url = URI('https://api.jetapi.io/api/v1/delivery')
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE # please use OpenSSL::SSL::VERIFY_PEER in production
request = Net::HTTP::Post.new(url)
request['authorization'] = 'Bearer yourtoken123456'
request['content-type'] = 'application/json'
request.body = { text: 'hello world', phone: '15551234567' }.to_json
response = http.request(request)
puts response.read_body
import Foundation
let session = URLSession.shared
let url = URL(string: "https://api.jetapi.io/api/v1/delivery")!
let headers = [
"Authorization": "Bearer yourtoken123456",
"Content-Type": "application/json"
]
let parameters = [
"text": "hello world",
"phone": "15551234567"
]
var request = URLRequest(
url: url,
cachePolicy: .reloadIgnoringLocalCacheData
)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = try JSONSerialization.data(withJSONObject: parameters, options: [])
let dataTask = session.dataTask(
with: request as URLRequest,
completionHandler: { data, _response, error in
if let error = error {
print("Error: \(error)")
return
}
if let data = data, let dataString = String(data: data, encoding: .utf8) {
print(dataString)
}
}
)
dataTask.resume()
params = %{text: "hello world", phone: "15551234567"}
url = "https://api.jetapi.io/api/v1/delivery"
token = "yourtoken123456"
request_headers = [
{"Content-Type", "application/json"},
{"Authorization", "Bearer #{token}"}
]
case HTTPoison.post(url, Jason.encode!(params), request_headers) do
{:ok, %HTTPoison.Response{status_code: 200, body: resp_body}} ->
IO.inspect(Jason.decode!(resp_body))
{:ok, %HTTPoison.Response{body: resp_body}} ->
IO.puts("Request error: #{resp_body}")
{:error, %HTTPoison.Error{reason: reason}} ->
IO.puts("Connection error: #{reason}")
end