Skip to main content

400 Client Error: Bad Request -Failed to evaluate script! evalscript.js:5: SyntaxError: Unexpected identifier

  • 26 April 2024
  • 2 replies
  • 5 views

Hello!


I’m trying to use sentinel hub request in order to retrieve senitnel-2 bands together with calculated NDVI, but I’m getting this error whenever I try to get the data:



DownloadFailedException: Failed to download from:
https://services.sentinel-hub

with HTTPError:

400 Client Error: Bad Request for url: https://services.sentinel-hub.com/api/

Server response: "{“error”:{“status”:400,“reason”:“Bad Request”,“message”:“Failed to evaluate script!\nevalscript.js:5: SyntaxError: Unexpected identifier\n input: p“B02,“B03”,“B04”,“B08”,“CLM”],\n ^^^\n”,“code”:“RENDERER_EXCEPTION”}}”



I could not find the problem with my evalscript. Thi sis my evalscript:


eval_sen2='''
//VERSION=3
function setup() {
return {
input: <"B02,"B03","B04","B08","CLM"],
output: {
bands: 4,
sampleType: "FLOAT32"
}
};
}

function evaluatePixel(sample) {
if (sample.CLM == 1) {
return lnull]
}
const ndvi = index(sample.B08, sample.B04);
return ondvi,sample.B02,sample.B03,sample.B04];
}
'''

My function to get the image:


def get_image(evalscript,geom,datacollection,time,bbox,bbox_size,path):

request = SentinelHubRequest(
data_folder=path,
evalscript=evalscript,
geometry=geom,
input_data=r
SentinelHubRequest.input_data(
data_collection=datacollection,
time_interval=time)],
responses=
SentinelHubRequest.output_response('default', MimeType.TIFF)
],
bbox=bbox,
size=bbox_size,
config=config)

img=request.get_data()


plt.figure(figsize=(10,4))
plt.matshow((img/3],imgp2],imgu1]),vmin=0,vmax=1,cmap='Spectral')
plt.show()


return img/0]


Then I try to retrieve the data using this script:



#geom is the geoemtry in sentinel hub, usig it to mask the tile with my polygon.

img_sen2=get_image(eval_sen2,geom,DataCollection.SENTINEL2_L2A,(d2,d2),bbox,bbox_size,'fake/path')



I could not find the mistake in the evalscript, please help me understand the error and fix the misake 🙂

There is a quote (") missing after B02. The error message does provide a hint where to look for…




reutkeller:


input: :"B02,"B03","B04","B08","CLM"],



should be
input: :"B02","B03","B04","B08","CLM"],


oops! is always the little things. Thank you for the help 🙂


Reply