Hi,
i am new with sentinel-hub and i need some help. I am trying to send a request with c# and .net but no luck.
This is my code. Any help will be apreciated, thanks:
JavaScriptSerializer js = new JavaScriptSerializer();
string clientID =xxxxxx;
string ClientSecret = xxxxx;
string APIUrl = ST_e03eb2a3ca5042cbafc7b8cad022a157.Properties.Resources.URL;
HttpClient client = new HttpClient(handler: httpClientHandler, disposeHandler: true);
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", ST_e03eb2a3ca5042cbafc7b8cad022a157.Properties.Resources.token);
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/tar"));
ServicePointManager.Expect100Continue = true;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
var request = new HttpRequestMessage();
request.Method = HttpMethod.Post;
request.RequestUri = new Uri(APIUrl);
var content = new MultipartFormDataContent();
content.Headers.ContentType.MediaType = "multipart/form-data";
var dataContent = new FormUrlEncodedContent(new[]
{
new KeyValuePair<string, string>("request", js.Serialize(fillInput())),
new KeyValuePair<string, string>("evalscript", ST_e03eb2a3ca5042cbafc7b8cad022a157.Properties.Resources.evalscript)
});
content.Add(dataContent);
request.Content = content;
var header = new ContentDispositionHeaderValue("form-data");
request.Content.Headers.ContentDisposition = header;
var response = client.PostAsync(request.RequestUri.ToString(), request.Content);
var result = response.Result;
And the parameters i send are two, input and evalscript.
The input parameter i serialize from an object that has something like this:
{"input": {
"bounds": {
"properties": {
"crs": "http://www.opengis.net/def/crs/OGC/1.3/CRS84"
},
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
12.480661,
41.965872
],
[
12.523909,
41.96817
],
[
12.553084,
41.931401
],
[
12.525968,
41.906365
],
[
12.491645,
41.894355
],
[
12.449084,
41.896911
],
[
12.433295,
41.926292
],
[
12.442219,
41.950043
],
[
12.480661,
41.965872
]
]
]
}
},
"data": [{
"type": "landsat-ot-l2",
"dataFilter": {
"timeRange": {
"from": "2020-07-01T00:00:00Z",
"to": "2020-07-31T00:00:00Z"
}
}
}]
},
"output": {
"width": 512,
"height": 512,
"responses": [{
"identifier": "default",
"format": {
"type": "image/tiff"
}
}]
}
}
}
and the evalscript has the string with the functions:
function setup() { return { input: [{ bands: ['B01', 'B02', 'B03', 'B04', 'B05', 'B06', 'B07', 'B10', 'BQA'] }], output: { id: 'default', bands: 9, sampleType: SampleType.UINT16 } } } function evaluatePixel(sample) { return [10000 * sample.B01, 10000 * sample.B02, 10000 * sample.B03, 10000 * sample.B04, 10000 * sample.B05, 10000 * sample.B06, 10000 * sample.B07, sample.B10, sample.BQA] }
thanks in advance