Bad Request in API

Hi,

I’m tryng to run an ESA’s challenge but in my linux distribution i receive always this response:

with HTTPError:

400 Client Error: Bad Request for url: https://services.sentinel-hub.com/api/v1/process
Server response: "{"error":{"status":400,"reason":"Bad Request","message":"Failed to evaluate script!\nevalscript.js:21: SyntaxError: Unexpected token <
                return {custom: [sample.Band(name='B01', units=(<Unit.REFLECTANCE: 'REFLECTANCE'>, <Unit.DN: 'DN'>), output_types=(<class 'numpy.float32'>, <class 'numpy.uint16'>)), sample.Band(name='B02', units=(<Unit.REFLECTANCE: 'REFLECTANCE'>, <Unit.DN: 'DN'>), output_types=(<class 'numpy.float32'>, <class 'numpy.uint16'>)), sample.Band(name='B03', units=(<Unit.REFLECTANCE: 'REFLECTANCE'>, <Unit.DN: 'DN'>), output_types=(<class 'numpy.float32'>, <class 'numpy.uint16'>)), sample.Band(name='B04', units=(<Unit.REFLECTANCE: 'REFLECTANCE'>, <Unit.DN: 'DN'>), output_types=(<class 'numpy.float32'>, <class 'numpy.uint16'>)), sample.Band(name='B05', units=(<Unit.REFLECTANCE: 'REFLECTANCE'>, <Unit.DN: 'DN'>), output_types=(<class 'numpy.float32'>, <class 'numpy.uint16'>)), sample.Band(name='B06', units=(<Unit.REFLECTANCE: 'REFLECTANCE'>, <Unit.DN: 'DN'>), output_types=(<class 'numpy.float32'>, <class 'numpy.uint16'>)), sample.Band(name='B07', units=(<Unit.REFLECTANCE: 'REFLECTANCE'>, <Unit.DN: 'DN'>), output_types=(<class 'numpy.float32'>, <class 'numpy.uint16'>)), sample.Band(name='B08', units=(<Unit.REFLECTANCE: 'REFLECTANCE'>, <Unit.DN: 'DN'>), output_types=(<class 'numpy.float32'>, <class 'numpy.uint16'>)), sample.Band(name='B8A', units=(<Unit.REFLECTANCE: 'REFLECTANCE'>, <Unit.DN: 'DN'>), output_types=(<class 'numpy.float32'>, <class 'numpy.uint16'>)), sample.Band(name='B09', units=(<Unit.REFLECTANCE: 'REFLECTANCE'>, <Unit.DN: 'DN'>), output_types=(<class 'numpy.float32'>, <class 'numpy.uint16'>)), sample.Band(name='B11', units=(<Unit.REFLECTANCE: 'REFLECTANCE'>, <Unit.DN: 'DN'>), output_types=(<class 'numpy.float32'>, <class 'numpy.uint16'>)), sample.Band(name='B12', units=(<Unit.REFLECTANCE: 'REFLECTANCE'>, <Unit.DN: 'DN'>), output_types=(<class 'numpy.float32'>, <class 'numpy.uint16'>))], bool_mask: [sample.dataMask], mask: [sample.SCL, sample.CLM], uint8_data: [sample.CLP]};"

,"code":"RENDERER_EXCEPTION"}}"

the challenge is this AI4EO

S2_TIME_INTERVAL = ('2019-03-01','2019-09-01')

S2_RESOLUTION = 10  # metres
S2_MAXCC = 0.5
S2_TIME_DELTA = 120

MAX_THREADS = 1

get_s2_l2a = SentinelHubInputTask(
    bands_feature=(FeatureType.DATA, 'BANDS'),
    bands_dtype=np.uint16,
    resolution=S2_RESOLUTION,
    maxcc=S2_MAXCC,
    time_difference=dt.timedelta(minutes=S2_TIME_DELTA),
    data_collection=DataCollection.SENTINEL2_L2A,
    additional_data=[(FeatureType.MASK, 'dataMask', 'IS_DATA'),
                     (FeatureType.MASK, 'SCL'),
                     (FeatureType.MASK, 'CLM'),
                     (FeatureType.DATA, 'CLP')],
    max_threads=MAX_THREADS,
    config=sh_config
)

s2_l2a_eop = get_s2_l2a.execute(bbox=bbox, time_interval=S2_TIME_INTERVAL)

Hello Andrea,

There have been some changes in Sentinel Hub in the last few months that unfortunately break this part.

To fix it please do the following:

  • upgrade sentinelhub by adding a cell at the beginning of the notebook as follows pip install --upgrade sentinelhub. The version needs to be 3.4.2
  • in cell 17, replace the line norm_factor = s2_l2a_eop.scalar['NORM_FACTORS'][tidx] with norm_factor = 1e-4

The scalar feature NORM_FACTORS no longer exists in the latest version but is replaced by the constant 1e-4.

You should then be able to run the notebook. Let us know if this works.

Hello and thank you for your answer.

I updated to 3.4.2 but in cell 14 i still have the same error

I don’t know how to solve it

Can you please report which eo-learn version is installed, and double-check the sh-py is the latest (restarting the kernel helps the uptake of changes)?

My working version has eo-learn 0.10.1.

Ty! eo-learn 0.10.1 solved it!