RateIt API (Deprecated)
Request Published Rates
Retrieve Published rates as per the contractual agreement.
Request
Request URL
Request headers
-
(optional)stringMedia type of the body sent to the API.
-
stringOAuth 2.0 access token obtained from JB Hunt OAuth 2.0 Test Provider. Supported grant types: Authorization code.
Request body
{
"origin": {
"streetAddress": "615 J B Hunt Corporate Dr",
"adminArea1": "AR",
"locality": "Lowell",
"postalCode": "72745",
"countryCode": "USA"
},
"destination": {
"streetAddress": "615 J B Hunt Corporate Dr",
"adminArea1": "AR",
"locality": "Lowell",
"postalCode": "72745",
"countryCode": "USA"
},
"pickupDate": "2019-11-01T00:00:00Z"
}
{
"title": "Published Rate Request",
"required": [
"origin",
"destination",
"pickupDate"
],
"type": "object",
"properties": {
"origin": {
"title": "Postal Address",
"required": [
"adminArea1",
"locality",
"postalCode",
"countryCode"
],
"type": "object",
"properties": {
"streetAddress": {
"type": "string",
"description": "address (eg. number, street, etc.).",
"example": "615 J B Hunt Corporate Dr"
},
"adminArea1": {
"type": "string",
"description": "Province, state, or [ISO-3166-2](https://en.wikipedia.org/wiki/ISO_3166-2) subdivision.",
"example": "AR"
},
"adminArea2": {
"type": "string",
"description": "Subdivision smaller than `adminArea1`. In the United States, this refers to county.",
"example": "Benton"
},
"locality": {
"type": "string",
"description": "City or town.",
"example": "Lowell"
},
"neighborhood": {
"type": "string",
"description": "neighborhood"
},
"postalCode": {
"type": "string",
"description": "ZIP, postcode, or postal code.",
"example": "72745"
},
"countryCode": {
"maxLength": 3,
"minLength": 3,
"pattern": "^[A-Z]{3}$",
"type": "string",
"description": "[ISO 3166-1 alpha-3](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-3) country code.",
"example": "USA"
}
},
"description": "Postal Address"
},
"destination": {
"title": "Postal Address",
"required": [
"adminArea1",
"locality",
"postalCode",
"countryCode"
],
"type": "object",
"properties": {
"streetAddress": {
"type": "string",
"description": "address (eg. number, street, etc.).",
"example": "615 J B Hunt Corporate Dr"
},
"adminArea1": {
"type": "string",
"description": "Province, state, or [ISO-3166-2](https://en.wikipedia.org/wiki/ISO_3166-2) subdivision.",
"example": "AR"
},
"adminArea2": {
"type": "string",
"description": "Subdivision smaller than `adminArea1`. In the United States, this refers to county.",
"example": "Benton"
},
"locality": {
"type": "string",
"description": "City or town.",
"example": "Lowell"
},
"neighborhood": {
"type": "string",
"description": "neighborhood"
},
"postalCode": {
"type": "string",
"description": "ZIP, postcode, or postal code.",
"example": "72745"
},
"countryCode": {
"maxLength": 3,
"minLength": 3,
"pattern": "^[A-Z]{3}$",
"type": "string",
"description": "[ISO 3166-1 alpha-3](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-3) country code.",
"example": "USA"
}
},
"description": "Postal Address"
},
"pickupDate": {
"type": "string",
"description": "[RFC 3339](https://tools.ietf.org/html/rfc3339#section-5.6) full-date specifying the pickup day.",
"format": "date",
"example": "2019-11-01T00:00:00Z"
},
"intermediateStops": {
"title": "Intermediate Stops",
"type": "array",
"items": {
"title": "Stop",
"required": [
"sequenceNumber",
"stopReason",
"location"
],
"type": "object",
"properties": {
"sequenceNumber": {
"type": "integer",
"description": "The stop number",
"format": "int32",
"example": 2
},
"stopReason": {
"enum": [
"Pickup",
"Delivery"
],
"type": "string",
"description": "Whether the stop is a pickup or a drop",
"example": "Pickup"
},
"location": {
"title": "Postal Address",
"required": [
"adminArea1",
"locality",
"postalCode",
"countryCode"
],
"type": "object",
"properties": {
"streetAddress": {
"type": "string",
"description": "address (eg. number, street, etc.).",
"example": "615 J B Hunt Corporate Dr"
},
"adminArea1": {
"type": "string",
"description": "Province, state, or [ISO-3166-2](https://en.wikipedia.org/wiki/ISO_3166-2) subdivision.",
"example": "AR"
},
"adminArea2": {
"type": "string",
"description": "Subdivision smaller than `adminArea1`. In the United States, this refers to county.",
"example": "Benton"
},
"locality": {
"type": "string",
"description": "City or town.",
"example": "Lowell"
},
"neighborhood": {
"type": "string",
"description": "neighborhood"
},
"postalCode": {
"type": "string",
"description": "ZIP, postcode, or postal code.",
"example": "72745"
},
"countryCode": {
"maxLength": 3,
"minLength": 3,
"pattern": "^[A-Z]{3}$",
"type": "string",
"description": "[ISO 3166-1 alpha-3](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-3) country code.",
"example": "USA"
}
},
"description": "Postal Address"
}
},
"description": "Stop details"
},
"description": "Stops that will be performed between the origin and destination"
},
"options": {
"title": "Rate Request Options",
"type": "object",
"properties": {
"weight": {
"title": "Weight",
"required": [
"units",
"value"
],
"type": "object",
"properties": {
"units": {
"enum": [
"Pounds",
"Kilograms"
],
"type": "string",
"description": "Weight units (allowed values - Pounds , Kilograms)",
"example": "Pounds"
},
"value": {
"type": "number",
"description": "Weight value",
"format": "double",
"example": 100.0
}
},
"description": "Total Weight for the shipment"
},
"containsHazardousMaterial": {
"type": "boolean",
"description": "Option if the shipment contains hazardous materials",
"example": false
},
"requestFuel": {
"type": "boolean",
"description": "Request fuel charges",
"example": true
},
"equipmentType": {
"title": "Equipment Type",
"type": "string",
"description": "Type of Equipment. Allowed values - Container, Dry Van, Reefer, Flatbed, 20TLR, 40TLR, 45TLR",
"example": "Flatbed"
},
"transportationMode": {
"title": "Transportation Mode",
"enum": [
"Truck",
"Rail"
],
"type": "string",
"description": "Transportation Mode (allowed values - Truck , Rail)",
"example": "Truck"
},
"accessorials": {
"title": "Accessorials Request",
"type": "array",
"items": {
"title": "Base Request Accessorial",
"required": [
"name"
],
"type": "object",
"properties": {
"name": {
"type": "string",
"description": "Accessorial charge code. Allowed values - CLEANTRK, DETENTION, DETENTIONP, DRVRLOAD, DRVRUNLD, EEIFILEFEE, INBOND, LUMPLOAD, LUMPUNLD, PALLETEXCH, SCALE CHRG, SDP, TARP4FT, TARP6FT, TARP8FT",
"example": "LUMPLOAD"
},
"stopSequenceNumber": {
"type": "integer",
"description": "The stop number",
"format": "int32",
"example": 2
},
"quantity": {
"title": "Measurement",
"required": [
"units",
"value"
],
"type": "object",
"properties": {
"units": {
"type": "string",
"description": "Unit of measure. Allowed values - Pounds, Kilograms, Flat, Days, Hours, Minutes, Pieces, Miles, Kilometers, Percent",
"example": "Pounds"
},
"value": {
"type": "number",
"description": "value of measurement",
"example": 10.0
}
},
"description": "Unit of measurement"
}
},
"description": "Accessorials charges requested to be included in rates response"
},
"description": "Accessorials charges requested to be included in rates response"
}
},
"description": "More options in requesting rates"
}
},
"description": "Request rates as per the contractual agreement",
"example": {
"origin": {
"streetAddress": "615 J B Hunt Corporate Dr",
"adminArea1": "AR",
"locality": "Lowell",
"postalCode": "72745",
"countryCode": "USA"
},
"destination": {
"streetAddress": "615 J B Hunt Corporate Dr",
"adminArea1": "AR",
"locality": "Lowell",
"postalCode": "72745",
"countryCode": "USA"
},
"pickupDate": "2019-11-01T00:00:00Z"
}
}
Responses
200 OK
Successfully received rates
Representations
{
"rate": [
{
"agreementIdentifier": "50",
"lineHaulCharge": {
"totalCost": {
"currencyCode": "USD",
"value": "1000.00"
},
"unitCost": {
"units": "PerMile",
"value": {
"currencyCode": "USD",
"value": "10.00"
}
},
"totalMiles": 100.0
},
"totalCharge": {
"currencyCode": "USD",
"value": "1050.00"
},
"accessorials": [
{
"name": "SUPINC",
"stopSequenceNumber": 1,
"quantity": {
"units": "Pounds",
"value": 10.0
},
"cost": {
"currencyCode": "USD",
"value": "50.00"
}
}
],
"transportationMode": "Truck",
"standardCarrierAlphaCode": "ABCD",
"messages": [
"Accessorial rate not available"
]
}
]
}
{
"title": "Published Rate Response",
"type": "object",
"properties": {
"rate": {
"type": "array",
"items": {
"title": "Rate",
"type": "object",
"properties": {
"agreementIdentifier": {
"type": "string",
"description": "Publication Code or AgreementID",
"example": "50"
},
"lineHaulCharge": {
"title": "Base Charge",
"type": "object",
"properties": {
"totalCost": {
"title": "Money",
"type": "object",
"properties": {
"currencyCode": {
"maxLength": 3,
"minLength": 3,
"type": "string",
"description": "Three-letter [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) currency code.",
"example": "USD"
},
"value": {
"maxLength": 32,
"pattern": "^((-?[0-9]+)|(-?([0-9]+)?[.][0-9]+))$",
"type": "string",
"description": "The value, which can be anything from:\n* An integer. For currencies that are not typically fractional, such as `JPY`.\n* A three-place decimal fraction. For currencies that are subdivided into thousandths, such as `TND`.\n* An eight-place decimal fraction. For currencies such as Bitcoin.\n* For the required number of decimal places for a currency code, see ISO 4217.\n",
"example": "10.00"
}
},
"description": "Money"
},
"unitCost": {
"title": "Discrete Charge",
"type": "object",
"properties": {
"units": {
"type": "string",
"description": "Unit of measure. Allowed values - PerMile, Flat"
},
"value": {
"title": "Money",
"type": "object",
"properties": {
"currencyCode": {
"maxLength": 3,
"minLength": 3,
"type": "string",
"description": "Three-letter [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) currency code.",
"example": "USD"
},
"value": {
"maxLength": 32,
"pattern": "^((-?[0-9]+)|(-?([0-9]+)?[.][0-9]+))$",
"type": "string",
"description": "The value, which can be anything from:\n* An integer. For currencies that are not typically fractional, such as `JPY`.\n* A three-place decimal fraction. For currencies that are subdivided into thousandths, such as `TND`.\n* An eight-place decimal fraction. For currencies such as Bitcoin.\n* For the required number of decimal places for a currency code, see ISO 4217.\n",
"example": "10.00"
}
},
"description": "Money"
}
},
"description": "Cost per unit of measurement"
},
"totalMiles": {
"type": "number",
"description": "Total Miles from origin to destination",
"format": "double",
"example": 1.0
}
},
"description": "Charge"
},
"totalCharge": {
"allOf": [
{
"title": "Money",
"type": "object",
"properties": {
"currencyCode": {
"maxLength": 3,
"minLength": 3,
"type": "string",
"description": "Three-letter [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) currency code.",
"example": "USD"
},
"value": {
"maxLength": 32,
"pattern": "^((-?[0-9]+)|(-?([0-9]+)?[.][0-9]+))$",
"type": "string",
"description": "The value, which can be anything from:\n* An integer. For currencies that are not typically fractional, such as `JPY`.\n* A three-place decimal fraction. For currencies that are subdivided into thousandths, such as `TND`.\n* An eight-place decimal fraction. For currencies such as Bitcoin.\n* For the required number of decimal places for a currency code, see ISO 4217.\n",
"example": "10.00"
}
},
"description": "Money"
}
],
"description": "Sum of `lineHaulCharge` and `accessorials`"
},
"accessorials": {
"title": "Accessorials Response",
"type": "array",
"items": {
"title": "Base Response Accessorial",
"required": [
"name"
],
"type": "object",
"properties": {
"name": {
"type": "string",
"description": "Accessorial charge code. Allowed values - CLEANTRK, DETENTION, DETENTIONP, DRVRLOAD, DRVRUNLD, EEIFILEFEE, INBOND, LUMPLOAD, LUMPUNLD, PALLETEXCH, SCALE CHRG, SDP, TARP4FT, TARP6FT, TARP8FT",
"example": "LUMPLOAD"
},
"stopSequenceNumber": {
"type": "integer",
"description": "The stop number",
"format": "int32",
"example": 2
},
"quantity": {
"title": "Measurement",
"required": [
"units",
"value"
],
"type": "object",
"properties": {
"units": {
"type": "string",
"description": "Unit of measure. Allowed values - Pounds, Kilograms, Flat, Days, Hours, Minutes, Pieces, Miles, Kilometers, Percent",
"example": "Pounds"
},
"value": {
"type": "number",
"description": "value of measurement",
"example": 10.0
}
},
"description": "Unit of measurement"
},
"cost": {
"title": "Money",
"type": "object",
"properties": {
"currencyCode": {
"maxLength": 3,
"minLength": 3,
"type": "string",
"description": "Three-letter [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) currency code.",
"example": "USD"
},
"value": {
"maxLength": 32,
"pattern": "^((-?[0-9]+)|(-?([0-9]+)?[.][0-9]+))$",
"type": "string",
"description": "The value, which can be anything from:\n* An integer. For currencies that are not typically fractional, such as `JPY`.\n* A three-place decimal fraction. For currencies that are subdivided into thousandths, such as `TND`.\n* An eight-place decimal fraction. For currencies such as Bitcoin.\n* For the required number of decimal places for a currency code, see ISO 4217.\n",
"example": "10.00"
}
},
"description": "Money"
}
},
"description": "Accessorial charges returned as part of the rate response"
},
"description": "Accessorial charges returned as part of the rate response"
},
"transportationMode": {
"title": "Transportation Mode",
"enum": [
"Truck",
"Rail"
],
"type": "string",
"description": "Transportation Mode (allowed values - Truck , Rail)",
"example": "Truck"
},
"standardCarrierAlphaCode": {
"pattern": "^[A-Z]{2,4}$",
"type": "string",
"description": "Standard Carrier Alpha Code (SCAC). It is typically two to four letters long given by the National Motor Freight Traffic Association.",
"example": "ABC"
},
"messages": {
"title": "Messages",
"type": "array",
"items": {
"title": "Base Message",
"type": "string",
"description": "Provides additional information about the rate"
},
"description": "Messages"
}
},
"description": "Requested rate as per the contractual agreement"
},
"description": "All rates requested as per the contractual agreement"
}
},
"description": "Published rates as per the contractual agreement",
"example": {
"rate": [
{
"agreementIdentifier": "50",
"lineHaulCharge": {
"totalCost": {
"currencyCode": "USD",
"value": "1000.00"
},
"unitCost": {
"units": "PerMile",
"value": {
"currencyCode": "USD",
"value": "10.00"
}
},
"totalMiles": 100.0
},
"totalCharge": {
"currencyCode": "USD",
"value": "1050.00"
},
"accessorials": [
{
"name": "SUPINC",
"stopSequenceNumber": 1,
"quantity": {
"units": "Pounds",
"value": 10.0
},
"cost": {
"currencyCode": "USD",
"value": "50.00"
}
}
],
"transportationMode": "Truck",
"standardCarrierAlphaCode": "ABCD",
"messages": [
"Accessorial rate not available"
]
}
]
}
}
400 Bad Request
The rate request has failed validation in some respect.
Representations
{
"id": "d5c0de15-7972-4de8-8395-04b14f7e92a6",
"errors": [
{
"title": "Invalid date",
"description": "The date provided is invalid",
"dateTime": "2019-01-01T00:00:00+00:00",
"details": [
{
"field": "$.pickupDate",
"location": "Body",
"value": "2019-01-02T00:00:00+00:00",
"issue": "Unable to parse date"
}
]
}
]
}
{
"title": "API Errors",
"type": "object",
"properties": {
"id": {
"type": "string",
"description": "UUID to be logged for correlation purposes",
"example": "d5c0de15-7972-4de8-8395-04b14f7e92a6"
},
"errors": {
"type": "array",
"items": {
"title": "API Error",
"required": [
"title",
"description",
"dateTime"
],
"type": "object",
"properties": {
"title": {
"type": "string",
"description": "Unique, human-readable name of the error"
},
"description": {
"type": "string",
"description": "Human-readable message describing the error"
},
"dateTime": {
"type": "string",
"description": "When the error occurred",
"format": "date-time"
},
"details": {
"type": "array",
"items": {
"title": "API Error Detail",
"required": [
"field",
"value",
"issue",
"location"
],
"type": "object",
"properties": {
"field": {
"type": "string",
"description": "JSON pointer referring to the field, if it is in the body; otherwise, name of the path or query parameter"
},
"value": {
"oneOf": [
{
"type": "boolean"
},
{
"type": "integer"
},
{
"type": "number"
},
{
"type": "string"
},
{
"type": "array"
},
{
"type": "object"
}
],
"description": "Value of the field in error",
"nullable": true
},
"issue": {
"type": "string",
"description": "Reason for the error"
},
"location": {
"enum": [
"Body",
"Header",
"Path",
"Query"
],
"type": "string",
"description": "Location of the field in error",
"default": "Body"
}
},
"description": "Detailed description of an individual API error"
},
"description": "Details of individual errors"
}
},
"description": "Information about an API error"
},
"description": "List of errors that occurred"
}
},
"example": {
"id": "d5c0de15-7972-4de8-8395-04b14f7e92a6",
"errors": [
{
"title": "Invalid date",
"description": "The date provided is invalid",
"dateTime": "2019-01-01T00:00:00Z",
"details": [
{
"field": "$.pickupDate",
"location": "Body",
"value": "2019-01-02T00:00:00Z",
"issue": "Unable to parse date"
}
]
}
]
}
}
500 Internal Server Error
A server-side error has occurred while attempting to retrieve the rate.
Representations
{
"id": "d5c0de15-7972-4de8-8395-04b14f7e92a6",
"errors": [
{
"title": "Invalid date",
"description": "The date provided is invalid",
"dateTime": "2019-01-01T00:00:00+00:00",
"details": [
{
"field": "$.pickupDate",
"location": "Body",
"value": "2019-01-02T00:00:00+00:00",
"issue": "Unable to parse date"
}
]
}
]
}
{
"title": "API Errors",
"type": "object",
"properties": {
"id": {
"type": "string",
"description": "UUID to be logged for correlation purposes",
"example": "d5c0de15-7972-4de8-8395-04b14f7e92a6"
},
"errors": {
"type": "array",
"items": {
"title": "API Error",
"required": [
"title",
"description",
"dateTime"
],
"type": "object",
"properties": {
"title": {
"type": "string",
"description": "Unique, human-readable name of the error"
},
"description": {
"type": "string",
"description": "Human-readable message describing the error"
},
"dateTime": {
"type": "string",
"description": "When the error occurred",
"format": "date-time"
},
"details": {
"type": "array",
"items": {
"title": "API Error Detail",
"required": [
"field",
"value",
"issue",
"location"
],
"type": "object",
"properties": {
"field": {
"type": "string",
"description": "JSON pointer referring to the field, if it is in the body; otherwise, name of the path or query parameter"
},
"value": {
"oneOf": [
{
"type": "boolean"
},
{
"type": "integer"
},
{
"type": "number"
},
{
"type": "string"
},
{
"type": "array"
},
{
"type": "object"
}
],
"description": "Value of the field in error",
"nullable": true
},
"issue": {
"type": "string",
"description": "Reason for the error"
},
"location": {
"enum": [
"Body",
"Header",
"Path",
"Query"
],
"type": "string",
"description": "Location of the field in error",
"default": "Body"
}
},
"description": "Detailed description of an individual API error"
},
"description": "Details of individual errors"
}
},
"description": "Information about an API error"
},
"description": "List of errors that occurred"
}
},
"example": {
"id": "d5c0de15-7972-4de8-8395-04b14f7e92a6",
"errors": [
{
"title": "Invalid date",
"description": "The date provided is invalid",
"dateTime": "2019-01-01T00:00:00Z",
"details": [
{
"field": "$.pickupDate",
"location": "Body",
"value": "2019-01-02T00:00:00Z",
"issue": "Unable to parse date"
}
]
}
]
}
}
Code samples
@ECHO OFF
curl -v -X POST "https://api.nonprod.jbhunt.com/rateit-api/published-rate"
-H "Content-Type: application/json"
-H "X-Api-Key: {subscription key}"
-H "Authorization: {access token}"
--data-ascii "{body}"
using System;
using System.Net.Http.Headers;
using System.Text;
using System.Net.Http;
using System.Web;
namespace CSHttpClientSample
{
static class Program
{
static void Main()
{
MakeRequest();
Console.WriteLine("Hit ENTER to exit...");
Console.ReadLine();
}
static async void MakeRequest()
{
var client = new HttpClient();
var queryString = HttpUtility.ParseQueryString(string.Empty);
// Request headers
client.DefaultRequestHeaders.Add("X-Api-Key", "{subscription key}");
client.DefaultRequestHeaders.Add("Authorization", "{access token}");
var uri = "https://api.nonprod.jbhunt.com/rateit-api/published-rate?" + queryString;
HttpResponseMessage response;
// Request body
byte[] byteData = Encoding.UTF8.GetBytes("{body}");
using (var content = new ByteArrayContent(byteData))
{
content.Headers.ContentType = new MediaTypeHeaderValue("< your content type, i.e. application/json >");
response = await client.PostAsync(uri, content);
}
}
}
}
// // This sample uses the Apache HTTP client from HTTP Components (http://hc.apache.org/httpcomponents-client-ga/)
import java.net.URI;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
public class JavaSample
{
public static void main(String[] args)
{
HttpClient httpclient = HttpClients.createDefault();
try
{
URIBuilder builder = new URIBuilder("https://api.nonprod.jbhunt.com/rateit-api/published-rate");
URI uri = builder.build();
HttpPost request = new HttpPost(uri);
request.setHeader("Content-Type", "application/json");
request.setHeader("X-Api-Key", "{subscription key}");
request.setHeader("Authorization", "{access token}");
// Request body
StringEntity reqEntity = new StringEntity("{body}");
request.setEntity(reqEntity);
HttpResponse response = httpclient.execute(request);
HttpEntity entity = response.getEntity();
if (entity != null)
{
System.out.println(EntityUtils.toString(entity));
}
}
catch (Exception e)
{
System.out.println(e.getMessage());
}
}
}
<!DOCTYPE html>
<html>
<head>
<title>JSSample</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
</head>
<body>
<script type="text/javascript">
$(function() {
var params = {
// Request parameters
};
$.ajax({
url: "https://api.nonprod.jbhunt.com/rateit-api/published-rate?" + $.param(params),
beforeSend: function(xhrObj){
// Request headers
xhrObj.setRequestHeader("Content-Type","application/json");
xhrObj.setRequestHeader("X-Api-Key","{subscription key}");
xhrObj.setRequestHeader("Authorization","{access token}");
},
type: "POST",
// Request body
data: "{body}",
})
.done(function(data) {
alert("success");
})
.fail(function() {
alert("error");
});
});
</script>
</body>
</html>
#import <Foundation/Foundation.h>
int main(int argc, const char * argv[])
{
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
NSString* path = @"https://api.nonprod.jbhunt.com/rateit-api/published-rate";
NSArray* array = @[
// Request parameters
@"entities=true",
];
NSString* string = [array componentsJoinedByString:@"&"];
path = [path stringByAppendingFormat:@"?%@", string];
NSLog(@"%@", path);
NSMutableURLRequest* _request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:path]];
[_request setHTTPMethod:@"POST"];
// Request headers
[_request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
[_request setValue:@"{subscription key}" forHTTPHeaderField:@"X-Api-Key"];
[_request setValue:@"{access token}" forHTTPHeaderField:@"Authorization"];
// Request body
[_request setHTTPBody:[@"{body}" dataUsingEncoding:NSUTF8StringEncoding]];
NSURLResponse *response = nil;
NSError *error = nil;
NSData* _connectionData = [NSURLConnection sendSynchronousRequest:_request returningResponse:&response error:&error];
if (nil != error)
{
NSLog(@"Error: %@", error);
}
else
{
NSError* error = nil;
NSMutableDictionary* json = nil;
NSString* dataString = [[NSString alloc] initWithData:_connectionData encoding:NSUTF8StringEncoding];
NSLog(@"%@", dataString);
if (nil != _connectionData)
{
json = [NSJSONSerialization JSONObjectWithData:_connectionData options:NSJSONReadingMutableContainers error:&error];
}
if (error || !json)
{
NSLog(@"Could not parse loaded json with error:%@", error);
}
NSLog(@"%@", json);
_connectionData = nil;
}
[pool drain];
return 0;
}
<?php
// This sample uses the Apache HTTP client from HTTP Components (http://hc.apache.org/httpcomponents-client-ga/)
require_once 'HTTP/Request2.php';
$request = new Http_Request2('https://api.nonprod.jbhunt.com/rateit-api/published-rate');
$url = $request->getUrl();
$headers = array(
// Request headers
'Content-Type' => 'application/json',
'X-Api-Key' => '{subscription key}',
'Authorization' => '{access token}',
);
$request->setHeader($headers);
$parameters = array(
// Request parameters
);
$url->setQueryVariables($parameters);
$request->setMethod(HTTP_Request2::METHOD_POST);
// Request body
$request->setBody("{body}");
try
{
$response = $request->send();
echo $response->getBody();
}
catch (HttpException $ex)
{
echo $ex;
}
?>
########### Python 2.7 #############
import httplib, urllib, base64
headers = {
# Request headers
'Content-Type': 'application/json',
'X-Api-Key': '{subscription key}',
'Authorization': '{access token}',
}
params = urllib.urlencode({
})
try:
conn = httplib.HTTPSConnection('api.nonprod.jbhunt.com')
conn.request("POST", "/rateit-api/published-rate?%s" % params, "{body}", headers)
response = conn.getresponse()
data = response.read()
print(data)
conn.close()
except Exception as e:
print("[Errno {0}] {1}".format(e.errno, e.strerror))
####################################
########### Python 3.2 #############
import http.client, urllib.request, urllib.parse, urllib.error, base64
headers = {
# Request headers
'Content-Type': 'application/json',
'X-Api-Key': '{subscription key}',
'Authorization': '{access token}',
}
params = urllib.parse.urlencode({
})
try:
conn = http.client.HTTPSConnection('api.nonprod.jbhunt.com')
conn.request("POST", "/rateit-api/published-rate?%s" % params, "{body}", headers)
response = conn.getresponse()
data = response.read()
print(data)
conn.close()
except Exception as e:
print("[Errno {0}] {1}".format(e.errno, e.strerror))
####################################
require 'net/http'
uri = URI('https://api.nonprod.jbhunt.com/rateit-api/published-rate')
request = Net::HTTP::Post.new(uri.request_uri)
# Request headers
request['Content-Type'] = 'application/json'
# Request headers
request['X-Api-Key'] = '{subscription key}'
# Request headers
request['Authorization'] = '{access token}'
# Request body
request.body = "{body}"
response = Net::HTTP.start(uri.host, uri.port, :use_ssl => uri.scheme == 'https') do |http|
http.request(request)
end
puts response.body