Planting Date - Beta
The Ag-Analytics Planting Date API uses machine learning models to give an estimate of the date that a certain crop was planted. This is a back-filling model meaning that it is used for determination of planting date for past years in fields where the true planting data is not known.
a) Planting Date - Beta
The Ag-Analytics® Planting Date API uses machine learning models to give an estimate of the date that a certain crop was planted. This is a back-filling model meaning that it is used for determination of planting date for past years in fields where the true planting data is not known.
Model Specifications
The planting date model relies on a several factors to determine the date. The current model inputs are information about location, soil characteristics, satellite imagery, and past weather data. By training a neural network on several thousand planting records obtained from farmers across the United States, the model achieves a high level of accuracy when tested against out-of-sample data. Future versions of the model will utilize greater amounts of acreage and more specific sets of variables as the driving factors are determined through research and testing. Further testing will determine the level of importance of each variable used to train the model, but the current variables are effective in estimation of planting date.
- Location: the location of the field can provide insight into the geospatial dependence on factors like climate and other local farming practices.
- Soil characteristics: data from both POLARIS and SSURGO are used as predictors of the planting date. The idea is that different soil types may correlate with the type of crops grown and when they are best planted.
- Satellite imagery: by using the Ag-Analytics® Harmonized Landsat Sentinel Service, the model obtains a wide array of multispectral bands for a growing season. Currently, short-wave infrared 1 and 2, RBG, and near-infrared bands are included in an 18-week window.
- Weather conditions: historical weather conditions are critical in determination of planting date because of the influence on field conditions. Extreme heat or cold and rain or drought can delay planting significantly, which changes the output of the model.
Request Parameters
Parameter | Date Type | Required? | Default | Options | Description |
---|---|---|---|---|---|
SHAPE | Geometry, file/text | Yes | -- | Geojson | Desired area-of-interest. See Fig. 1 for example. |
ModelType | Text String | No | Neural Network |
“NN” (Neural Network) “TREE” (Decision Tree) |
Type of model to use for prediction. Default is neural network. Not necessary to specify for most cases. |
CropSeason | Text | Yes | -- | 2013 -2019 | The year of interest to retrieve the crop type information. Ex. “2018” |
Response Parameters
Parameter | Date Type | Required? |
---|---|---|
feature_averages |
List |
Averages of the bi-week remote sensing data and monthly weather data of the area-of-interest: I. Greenweek#: Green band value on the # week of the year II. Blueweek#: Blue band value on the # week of the year III. Redweek#: Red band value on the # week of the year IV. NIRweek#: Near Infrared band value on the # week of the year V. SWIR1week#: Shortwave Infrared band 1 value on the # week of the year VI. SWIR2week#: Shortwave Infrared band 2 value on the # week of the year VII. GDD#: Monthly growing degree days VIII. Precipitation#: Monthly precipitation |
raster_filename | - | URL to download result raster (.tif) file. |
rasterinfo. attributes.CellSize | Resolution | Resolution of result Geotiff file in meters. |
rasterinfo. attributes.CoordinateSystem | - | Information about the projection of the raster. |
rasterinfo. attributes.Extent | - | Extents of the result raster. Specifies the bottom left and top right corners of the field raster in degrees. |
rasterinfo. attributes.Legend | List | Legend gives the following details for each range of values: I. Area: Area covered II. Count: # of pixels from the result raster in that range III. CountAllPixels: Total # of pixels in the result raster IV. Max: Max value in the range V. Min: Minimum value in the range VI. Mean: Mean value in the range VII. Color: Hex color used for the crop type |
rasterinfo.attributes.Matrix | List | Row and columns, containing attributes below. |
rasterinfo.attributes.Max | Number | Maximum value from the result raster. |
rasterinfo.attributes.Min | Number | Minimum value from the result raster. |
rasterinfo.attributes.Mean | Number | Average value from the result raster. |
rasterinfo.attributes.Percentile5 | Number | 5th percentile value from the result raster. |
rasterinfo.attributes.Percentile95 | Number | 95th percentile value from the result raster. |
rasterinfo. attributes.pngb64 | Link | Base64png image of the result raster with legend entries. |
Shape Example - GeoJSON
"{\"type\":\"Feature\",\"properties\":{},\"geometry\":{\"type\":\"Polygon\",\"coordinates\":[[[-100.953840994,38.5946753571],[-100.953832008,38.5948720599],[-100.953876941,38.5952162884],[-100.953957821,38.5955324152],[-100.953984781,38.5955745654],[-100.954029714,38.5957361407],[-100.954245394,38.5961716896],[-100.954452087,38.5964807873],[-100.95473966,38.5968179832],[-100.954910406,38.596965506],[-100.954910406,38.5969795557],[-100.954982299,38.5970287299],[-100.954982299,38.5970427797],[-100.955359739,38.5973378239],[-100.955377712,38.5973378239],[-100.955629338,38.5975134449],[-100.956042724,38.5977312143],[-100.956357257,38.5978646856],[-100.956707736,38.5979911318],[-100.957175042,38.598110553],[-100.957615388,38.5981878255],[-100.958055734,38.598229974],[-100.958514053,38.5982369988],[-100.958963386,38.5982088998],[-100.959412719,38.5981456769],[-100.959906984,38.5980332805],[-100.96023949,38.5979279087],[-100.960598957,38.5977874128],[-100.960976396,38.5976047676],[-100.961281942,38.597422122],[-100.961560528,38.5972113765],[-100.961578502,38.5972113765],[-100.961848101,38.5969865806],[-100.961982901,38.5968390579],[-100.962018848,38.5968179832],[-100.962189594,38.5966283107],[-100.962315407,38.5964526876],[-100.962405274,38.5964526876],[-100.962405274,38.5963894631],[-100.962369327,38.5963894631],[-100.962369327,38.5963754133],[-100.962513113,38.5961716896],[-100.96262994,38.5959539155],[-100.962800686,38.5955324152],[-100.962908526,38.595054712],[-100.962926499,38.5948580097],[-100.962890553,38.5948509846],[-100.962962446,38.5948650348],[-100.963025352,38.5947947839],[-100.962998393,38.5947877588],[-100.962989406,38.5947666835],[-100.962917513,38.5947526333],[-100.962935486,38.5947245329],[-100.962926499,38.5946894073],[-100.962881566,38.5947034575],[-100.962665886,38.5946823822],[-100.958541013,38.5946753571],[-100.9584152,38.5947175077],[-100.958316347,38.5947175077],[-100.958298374,38.5947034575],[-100.958154587,38.5946753571],[-100.953840994,38.5946753571]]]}}"
Request Example - application/json
application/json
{"SHAPE": "{\"type\":\"Feature\",\"properties\":{},\"geometry\":{\"type\":\"Polygon\",\"coordinates\":[[[-100.953840994,38.5946753571],[-100.953832008,38.5948720599],[-100.953876941,38.5952162884],[-100.953957821,38.5955324152],[-100.953984781,38.5955745654],[-100.954029714,38.5957361407],[-100.954245394,38.5961716896],[-100.954452087,38.5964807873],[-100.95473966,38.5968179832],[-100.954910406,38.596965506],[-100.954910406,38.5969795557],[-100.954982299,38.5970287299],[-100.954982299,38.5970427797],[-100.955359739,38.5973378239],[-100.955377712,38.5973378239],[-100.955629338,38.5975134449],[-100.956042724,38.5977312143],[-100.956357257,38.5978646856],[-100.956707736,38.5979911318],[-100.957175042,38.598110553],[-100.957615388,38.5981878255],[-100.958055734,38.598229974],[-100.958514053,38.5982369988],[-100.958963386,38.5982088998],[-100.959412719,38.5981456769],[-100.959906984,38.5980332805],[-100.96023949,38.5979279087],[-100.960598957,38.5977874128],[-100.960976396,38.5976047676],[-100.961281942,38.597422122],[-100.961560528,38.5972113765],[-100.961578502,38.5972113765],[-100.961848101,38.5969865806],[-100.961982901,38.5968390579],[-100.962018848,38.5968179832],[-100.962189594,38.5966283107],[-100.962315407,38.5964526876],[-100.962405274,38.5964526876],[-100.962405274,38.5963894631],[-100.962369327,38.5963894631],[-100.962369327,38.5963754133],[-100.962513113,38.5961716896],[-100.96262994,38.5959539155],[-100.962800686,38.5955324152],[-100.962908526,38.595054712],[-100.962926499,38.5948580097],[-100.962890553,38.5948509846],[-100.962962446,38.5948650348],[-100.963025352,38.5947947839],[-100.962998393,38.5947877588],[-100.962989406,38.5947666835],[-100.962917513,38.5947526333],[-100.962935486,38.5947245329],[-100.962926499,38.5946894073],[-100.962881566,38.5947034575],[-100.962665886,38.5946823822],[-100.958541013,38.5946753571],[-100.9584152,38.5947175077],[-100.958316347,38.5947175077],[-100.958298374,38.5947034575],[-100.958154587,38.5946753571],[-100.953840994,38.5946753571]]]}}",
"ScalarVariables": {
"CropSeason": "2018"
},
"ModelType":"NN"
}
Response Example - application/json
{
"feature_averages": [
{"Key": "Greenweek18","Value": 1218.6882460676118},
{"Key": "Redweek18","Value": 1276.7237154230897},
{ "Key": "SWIR2week18","Value": 50.21536849730397},
{"Key": "SWIR1week18","Value": 2366.0455730402196},
{"Key": "NIRweek18","Value": 2819.818161154887},
{"Key": "Blueweek18","Value": 1599.2762531927453},
{"Key": "Greenweek20","Value": 957.1687156481621},
{"Key": "Redweek20","Value": 980.6943679720338},
{"Key": "SWIR2week20","Value": 997.2153896961564},
{"Key": "SWIR1week20","Value": 1559.769602306673},
{"Key": "NIRweek20","Value": 2616.383912450711},
{"Key": "Blueweek20","Value": 662.1803611724483
{"Key": "Greenweek22", "Value": 865.8829308328359},
{"Key": "Redweek22","Value": 895.5443958071401},
{"Key": "SWIR2week22","Value": 1306.0237171209133},
{"Key": "SWIR1week22","Value": 1848.4805423326445},
{"Key": "NIRweek22","Value": 2665.3743359990017},
{"Key": "Blueweek22","Value": 599.7110449794816},
{"Key": "Greenweek24","Value": 4469.372969613223},
{"Key": "Redweek24","Value": 4543.523878522247},
{"Key": "SWIR2week24","Value": 3726.222820849983},
{"Key": "SWIR1week24","Value": 6503.78555606734},
{"Key": "NIRweek24","Value": 6454.815507608226},
{"Key": "Blueweek24","Value": 3658.3995564435445
{"Key": "Greenweek26","Value": 1508.828147157162},
{"Key": "Redweek26","Value": 1522.5964741037603},
{"Key": "SWIR2week26", "Value": 11.014840519379991},
{"Key": "SWIR1week26","Value": 432.26650756358885},
{"Key": "NIRweek26","Value": 3462.8701202282755},
{"Key": "Blueweek26","Value": 1283.8910904532877},
{"Key": "Greenweek28","Value": 897.9982080017721},
{"Key": "Redweek28","Value": 931.8507324987523},
{"Key": "SWIR1week28", "Value": 1571.3495378790276},
{"Key": "SWIR2week28","Value": 1027.1511365545261},
{"Key": "NIRweek28", "Value": 2740.6613500734948},
{"Key": "Blueweek28","Value": 644.8779364279997
{"Key": "Greenweek30","Value": 5864.923760534673},
{"Key": "Redweek30","Value": 795.3165483552489},
{"Key": "SWIR2week30","Value": 13.257439456487957},
{"Key": "SWIR1week30","Value": 767.7595418620314},
{"Key": "NIRweek30","Value": 5732.150236664299},
{"Key": "Blueweek30","Value": 8131.229142339392},
{"Key": "Greenweek32","Value": 731.9143641948485},
{"Key": "Redweek32","Value": 807.0480643287201},
{"Key": "SWIR2week32","Value": 10.802104931021402},
{"Key": "SWIR1week32","Value": 472.45490145887067},
{"Key": "NIRweek32","Value": 2515.4616126482197},
{"Key": "Blueweek32","Value": 533.4108390157562},
{"Key": "Greenweek34","Value": 896.549034849674},
{"Key": "Redweek34","Value": 959.7777929988146},
{"Key": "SWIR2week34","Value": 1502.5244706428862},
{"Key": "SWIR1week34","Value": 2038.150860812607},
{"Key": "NIRweek34","Value": 2408.0119739829343},
{"Key": "Blueweek34","Value": 763.9157193529676},
{"Key": "Greenweek36","Value": 918.9698085947933},
{"Key": "Redweek36","Value": 984.9548189503837},
{"Key": "SWIR2week36","Value": 1299.9700718861252},
{"Key": "SWIR1week36","Value": 1977.4707248154064},
{"Key": "NIRweek36","Value": 2628.78016105923},
{"Key": "Blueweek36","Value": 696.3513398537269},
{"Key": "GDD3","Value": 0.0},
{"Key": "Precipitation3","Value": 67.55299999999998},
{"Key": "GDD4","Value": 51.91649999999999},
{"Key": "Precipitation4","Value": 34.26099999999999},
{"Key": "GDD5","Value": 591.183},
{"Key": "Precipitation5","Value": 120.82300000000002},
{"Key": "GDD6","Value": 736.1180999999997},
{"Key": "Precipitation6","Value": 196.54299999999992},
{"Key": "GDD7","Value": 206.43119999999996},
{"Key": "Precipitation7","Value": 109.73999999999998},
{"Key": "GDD8","Value": 0.0},
{"Key": "Precipitation8","Value": 0.0}
],
"raster_filename": "result_cropidraster_20191127_202623_9621.tif",
"rasterinfo": [
{
"attributes": {
"CellSize": [
0.0001,
-0.0001
],
"CoordinateSystem": "GEOGCS[\"WGS 84\",DATUM[\"WGS_1984\",SPHEROID[\"WGS 84\",6378137,298.257223563,AUTHORITY[\"EPSG\",\"7030\"]],AUTHORITY[\"EPSG\",\"6326\"]],PRIMEM[\"Greenwich\",0],UNIT[\"degree\",0.0174532925199433],AUTHORITY[\"EPSG\",\"4326\"]]",
"Extent": "-93.7759549449, 41.6147830947, -93.77465494489999, 41.6513830947",
"Legend": [
{
"Area": "1.44 %",
"Count": 64,
"CountAllPixels": 4446,
"Max": 119.84002962820219,
"Mean": 99.1953509709138,
"Min": 78.5506723136254,
"color": "#FF0000"
},
{
"Area": "9.36 %",
"Count": 416,
"CountAllPixels": 4446,
"Max": 161.12938694277898,
"Mean": 140.48470828549057,
"Min": 119.84002962820219,
"color": "#FF6666"
},
{
"Area": "89.2 %",
"Count": 3966,
"CountAllPixels": 4446,
"Max": 202.41874425735574,
"Mean": 181.77406560006736,
"Min": 161.12938694277898,
"color": "#FFFF66"
}
],
"Matrix": [
366,
13
],
"Max": 202.41874425735574,
"Mean": 168.44008744627573,
"Min": 78.5506723136254,
"OID": 0,
"Percentile5": 152.23603227084163,
"Percentile95": 172.45018523462116,
"Variety": "NoVariety",
"pngb64": "data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAA0AAAFuCAYAAABa/JI8AAACnUlEQVR4nO2cYZKDIAyFY6dn1TPJZd0f6goxIQm2jtr3ZnbaOn4EMIQAzna0aOr7ibjG7PtA1KXUERG9djdWNE1zwe/iakrMUi/CJdTLN3Ft1eNWXFBNQ/mz3iay2uRsD5FUvZF9H3d3ONvEwNDDXfUWrwpV0i0ZN8uQUwc94tBzcqjsPeZjWseUltZ2pVS2seqwXNzyDspLNjqlrF545EqA4uX7NmmulNJ/oPmi7zEX26CaFdbeg15uKbN2Xow4D9LHU+UR6JYG5XsBWaM284q97zn8r4SUkar7HtfAPjOVvTeyT8Wy7eUpBb3cFfckCbHj4MjVNO6tfXD6lKyRNHK7NP+FLB2a1DT/E6G1Wx1evlVv+vKcK0MDVdv2hRBmjidJKW1VVQNLfjOR+sA/ODRyC+50lK0xeDX1ocFB05KhK86E4Yma6b2uviLyW8o64+IpAaC7QY4pZoPyuO0EG9eEq8sHps85hDnXGJulBt0aUuZeX14esvRJyDc/fcISoKdAVS+XvFpNEnncc6x17UEopm78orEeJLLiXrh6GE+KskdwxeoBWhTKloXZ0N4laD4DeApUTQmkBMNIFrcud+7Kz5ace3ol5ChZh3IZBcj7e02WAAH6eUiPEUTq+IodxC2FNMUIfbgPwjUR0gpguvhzAgQI0N2gaeqnV2QzsLRkHOjIEFEwwgZzvdLSj0P2qkbY1Lh4m24NNZ1INlk6BwpvE+d5kWtFLSVSDJSTxNALcg6gtHR4IfkLkLnHEnrVIaA6xN/jW9SJ57laFRcH8L+ced5O4hNPjpt6T+yIcMYSzI8OTNTnHGM253vnQMj3AAECBEgWTiSPQE/MjQABAgQIECBAgAABAgQIECBAgAABAgQIEL/QdfM/3arpDxgQh6yqLAyQAAAAAElFTkSuQmCC"
}
}
]
}
Call API
Request
Request URL
Request headers
-
(optional)string
Request body
{
"SHAPE": "{\"type\":\"Feature\",\"properties\":{},\"geometry\":{\"type\":\"Polygon\",\"coordinates\":[[[-100.953840994,38.5946753571],[-100.953832008,38.5948720599],[-100.953876941,38.5952162884],[-100.953957821,38.5955324152],[-100.953984781,38.5955745654],[-100.954029714,38.5957361407],[-100.954245394,38.5961716896],[-100.954452087,38.5964807873],[-100.95473966,38.5968179832],[-100.954910406,38.596965506],[-100.954910406,38.5969795557],[-100.954982299,38.5970287299],[-100.954982299,38.5970427797],[-100.955359739,38.5973378239],[-100.955377712,38.5973378239],[-100.955629338,38.5975134449],[-100.956042724,38.5977312143],[-100.956357257,38.5978646856],[-100.956707736,38.5979911318],[-100.957175042,38.598110553],[-100.957615388,38.5981878255],[-100.958055734,38.598229974],[-100.958514053,38.5982369988],[-100.958963386,38.5982088998],[-100.959412719,38.5981456769],[-100.959906984,38.5980332805],[-100.96023949,38.5979279087],[-100.960598957,38.5977874128],[-100.960976396,38.5976047676],[-100.961281942,38.597422122],[-100.961560528,38.5972113765],[-100.961578502,38.5972113765],[-100.961848101,38.5969865806],[-100.961982901,38.5968390579],[-100.962018848,38.5968179832],[-100.962189594,38.5966283107],[-100.962315407,38.5964526876],[-100.962405274,38.5964526876],[-100.962405274,38.5963894631],[-100.962369327,38.5963894631],[-100.962369327,38.5963754133],[-100.962513113,38.5961716896],[-100.96262994,38.5959539155],[-100.962800686,38.5955324152],[-100.962908526,38.595054712],[-100.962926499,38.5948580097],[-100.962890553,38.5948509846],[-100.962962446,38.5948650348],[-100.963025352,38.5947947839],[-100.962998393,38.5947877588],[-100.962989406,38.5947666835],[-100.962917513,38.5947526333],[-100.962935486,38.5947245329],[-100.962926499,38.5946894073],[-100.962881566,38.5947034575],[-100.962665886,38.5946823822],[-100.958541013,38.5946753571],[-100.9584152,38.5947175077],[-100.958316347,38.5947175077],[-100.958298374,38.5947034575],[-100.958154587,38.5946753571],[-100.953840994,38.5946753571]]]}}",
"ScalarVariables": {"CropSeason": "2018"},
"ModelType":"NN"
}
{
"SHAPE": "{\"type\":\"Feature\",\"properties\":{},\"geometry\":{\"type\":\"Polygon\",\"coordinates\":[[[-100.953840994,38.5946753571],[-100.953832008,38.5948720599],[-100.953876941,38.5952162884],[-100.953957821,38.5955324152],[-100.953984781,38.5955745654],[-100.954029714,38.5957361407],[-100.954245394,38.5961716896],[-100.954452087,38.5964807873],[-100.95473966,38.5968179832],[-100.954910406,38.596965506],[-100.954910406,38.5969795557],[-100.954982299,38.5970287299],[-100.954982299,38.5970427797],[-100.955359739,38.5973378239],[-100.955377712,38.5973378239],[-100.955629338,38.5975134449],[-100.956042724,38.5977312143],[-100.956357257,38.5978646856],[-100.956707736,38.5979911318],[-100.957175042,38.598110553],[-100.957615388,38.5981878255],[-100.958055734,38.598229974],[-100.958514053,38.5982369988],[-100.958963386,38.5982088998],[-100.959412719,38.5981456769],[-100.959906984,38.5980332805],[-100.96023949,38.5979279087],[-100.960598957,38.5977874128],[-100.960976396,38.5976047676],[-100.961281942,38.597422122],[-100.961560528,38.5972113765],[-100.961578502,38.5972113765],[-100.961848101,38.5969865806],[-100.961982901,38.5968390579],[-100.962018848,38.5968179832],[-100.962189594,38.5966283107],[-100.962315407,38.5964526876],[-100.962405274,38.5964526876],[-100.962405274,38.5963894631],[-100.962369327,38.5963894631],[-100.962369327,38.5963754133],[-100.962513113,38.5961716896],[-100.96262994,38.5959539155],[-100.962800686,38.5955324152],[-100.962908526,38.595054712],[-100.962926499,38.5948580097],[-100.962890553,38.5948509846],[-100.962962446,38.5948650348],[-100.963025352,38.5947947839],[-100.962998393,38.5947877588],[-100.962989406,38.5947666835],[-100.962917513,38.5947526333],[-100.962935486,38.5947245329],[-100.962926499,38.5946894073],[-100.962881566,38.5947034575],[-100.962665886,38.5946823822],[-100.958541013,38.5946753571],[-100.9584152,38.5947175077],[-100.958316347,38.5947175077],[-100.958298374,38.5947034575],[-100.958154587,38.5946753571],[-100.953840994,38.5946753571]]]}}",
"ScalarVariables": {"CropSeason": "2018"},
"ModelType":"NN"
}
Responses
200 OK
Code samples
@ECHO OFF
curl -v -X POST "https://ag-analytics.azure-api.net/plantingdate/"
-H "Content-Type: application/json"
--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
var uri = "https://ag-analytics.azure-api.net/plantingdate/?" + 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://ag-analytics.azure-api.net/plantingdate/");
URI uri = builder.build();
HttpPost request = new HttpPost(uri);
request.setHeader("Content-Type", "application/json");
// 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://ag-analytics.azure-api.net/plantingdate/?" + $.param(params),
beforeSend: function(xhrObj){
// Request headers
xhrObj.setRequestHeader("Content-Type","application/json");
},
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://ag-analytics.azure-api.net/plantingdate/";
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 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://ag-analytics.azure-api.net/plantingdate/');
$url = $request->getUrl();
$headers = array(
// Request headers
'Content-Type' => 'application/json',
);
$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',
}
params = urllib.urlencode({
})
try:
conn = httplib.HTTPSConnection('ag-analytics.azure-api.net')
conn.request("POST", "/plantingdate/?%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',
}
params = urllib.parse.urlencode({
})
try:
conn = http.client.HTTPSConnection('ag-analytics.azure-api.net')
conn.request("POST", "/plantingdate/?%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://ag-analytics.azure-api.net/plantingdate/')
request = Net::HTTP::Post.new(uri.request_uri)
# Request headers
request['Content-Type'] = 'application/json'
# 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