curl --request POST \
--url https://ruangapi.com/api/v1/shipping \
--header 'accept: application/json' \
--header 'authorization: your-api-key' \
--header 'content-type: application/json' \
--data 'origin=22&destination=14&weight=800&courier=jne'
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://ruangapi.com/api/v1/shipping",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "origin=22&destination=14&weight=800&courier=jne",
CURLOPT_HTTPHEADER => array(
"accept: application/json",
"authorization: your-api-key",
"content-type: application/json"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
var unirest = require("unirest");
var req = unirest("POST", "https://ruangapi.com/api/v1/shipping");
req.headers({
"authorization": "your-api-key",
"accept": "application/json",
"content-type": "application/json"
});
req.send("origin=22&destination=14&weight=800&courier=jne");
req.end(function (res) {
if (res.error) throw new Error(res.error);
console.log(res.body);
});
HttpResponse<String> response = Unirest.post("https://ruangapi.com/api/v1/shipping")
.header("authorization", "your-api-key")
.header("accept", "application/json")
.header("content-type", "application/json")
.body("origin=22&destination=14&weight=800&courier=jne")
.asString();
import requests
url = "https://ruangapi.com/api/v1/shipping"
payload = "origin=22&destination=14&weight=800&courier=jne"
headers = {
'authorization': "your-api-key",
'accept': "application/json",
'content-type': "application/json"
}
response = requests.request("POST", url, data=payload, headers=headers)
print(response.text)
require 'uri'
require 'net/http'
require 'openssl'
url = URI("https://ruangapi.com/api/v1/shipping")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Post.new(url)
request["authorization"] = 'your-api-key'
request["accept"] = 'application/json'
request["content-type"] = 'application/json'
request.body = "origin=22&destination=14&weight=800&courier=jne"
response = http.request(request)
puts response.read_body
#import <Foundation/Foundation.h>
NSDictionary *headers = @{ @"authorization": @"your-api-key",
@"accept": @"application/json",
@"content-type": @"application/json" };
NSData *postData = [[NSData alloc] initWithData:[@"origin=22&destination=14&weight=800&courier=jne" dataUsingEncoding:NSUTF8StringEncoding]];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://ruangapi.com/api/v1/shipping"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
[request setHTTPMethod:@"POST"];
[request setAllHTTPHeaderFields:headers];
[request setHTTPBody:postData];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSLog(@"%@", httpResponse);
}
}];
[dataTask resume];
package main
import (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main() {
url := "https://ruangapi.com/api/v1/shipping"
payload := strings.NewReader("origin=22&destination=14&weight=800&courier=jne")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("authorization", "your-api-key")
req.Header.Add("accept", "application/json")
req.Header.Add("content-type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}