COMMON_BAD_PAYLOAD using Request Builder and Sentinel 1 examples

I’m running this to try and request a time series of Sentinel-1 data for an aoi.

from sentinelhub import SentinelHubRequest, SentinelHubDownloadClient, DataCollection, MimeType, DownloadRequest, CRS, BBox, SHConfig, Geometry
config = SHConfig()
# https://docs.sentinel-hub.com/api/latest/evalscript/v3/
# mosaicking of TILE means full time series returned without mosaicking
evalscript = """
//VERSION=3
function setup() {
  return {
    input: ["VV", "localIncidenceAngle", "scatteringArea", "shadowMask"],
    output: [{ id:"s1_rtc_VV_area", bands: 2, sampleType: "FLOAT32"},
             { id:"s1_rtc_angle_mask", bands: 2, sampleType: "UINT8"}],
    mosaicking: "TILE"
  }
}
function evaluatePixel(samples){
    return {
    s1_rtc_VV_area: [10 * Math.log(samples.VV) / Math.LN10, samples.scatteringArea],
    s1_rtc_angle_mask: [samples.localIncidenceAngle, samples.shadowMask]
   }
}
"""
bbox = BBox(bbox=[-63.335390675843286, -19.315383298843127, -61.39430647448334, -17.462644319757963], crs=CRS.WGS84)
geometry = Geometry(geometry={"type":"Polygon","coordinates":[[[-63.335391,-19.25932],[-61.440385,-19.315384],[-61.394307,-17.513133],[-63.269917,-17.462645],[-63.335391,-19.25932]]]}, crs=CRS.WGS84)

request = SentinelHubRequest(
  evalscript=evalscript,
  input_data=[
    SentinelHubRequest.input_data(
    data_collection=DataCollection.SENTINEL1_IW_ASC,
    time_interval=('2014-10-01', '2016-09-30'),    
      other_args = {"dataFilter":{"resolution":"HIGH"},"processing":{"orthorectify":True,"demInstance":"COPERNICUS_30","backCoeff":"GAMMA0_TERRAIN"}}
)
  ],
  responses=[
    SentinelHubRequest.output_response('default', MimeType.TIFF),
    
  ],
  bbox=bbox,  
  geometry=geometry,
  size=[512, 512.31],
  config=config
)
response = request.get_data() 

This results in this error. I think I’m supposed to change response=SentinelHubRequest.ouput_response("default", MimeType.TIFF) to not be “default” but I can’t find any examples of what should go here if I’m not requesting and id of “default” and if I have multiple ids to request.

---------------------------------------------------------------------------
HTTPError                                 Traceback (most recent call last)
~/miniconda3/lib/python3.8/site-packages/sentinelhub/download/handlers.py in new_download_func(self, request)
     21         try:
---> 22             return download_func(self, request)
     23         except requests.HTTPError as exception:

~/miniconda3/lib/python3.8/site-packages/sentinelhub/download/sentinelhub_client.py in _execute_download(self, request)
     55                 if response.status_code != requests.status_codes.codes.TOO_MANY_REQUESTS:
---> 56                     response.raise_for_status()
     57 

~/miniconda3/lib/python3.8/site-packages/requests/models.py in raise_for_status(self)
    940         if http_error_msg:
--> 941             raise HTTPError(http_error_msg, response=self)
    942 

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

The above exception was the direct cause of the following exception:

DownloadFailedException                   Traceback (most recent call last)
<ipython-input-2-7240051e6205> in <module>
     39   config=config
     40 )
---> 41 response = request.get_data()

~/miniconda3/lib/python3.8/site-packages/sentinelhub/data_request.py in get_data(self, save_data, redownload, data_filter, max_threads, decode_data, raise_download_errors)
    124         """
    125         self._preprocess_request(save_data, True)
--> 126         return self._execute_data_download(data_filter, redownload, max_threads, raise_download_errors,
    127                                            decode_data=decode_data)
    128 

~/miniconda3/lib/python3.8/site-packages/sentinelhub/data_request.py in _execute_data_download(self, data_filter, redownload, max_threads, raise_download_errors, decode_data)
    184             config=self.config
    185         )
--> 186         data_list = client.download(filtered_download_list, max_threads=max_threads, decode_data=decode_data)
    187 
    188         if is_repeating_filter:

~/miniconda3/lib/python3.8/site-packages/sentinelhub/download/client.py in download(self, download_requests, max_threads, decode_data)
     77                 if self.raise_download_errors:
     78                     traceback = sys.exc_info()[2]
---> 79                     raise download_exception.with_traceback(traceback)
     80 
     81                 warnings.warn(str(download_exception), category=SHRuntimeWarning)

~/miniconda3/lib/python3.8/site-packages/sentinelhub/download/client.py in download(self, download_requests, max_threads, decode_data)
     73         for future in download_list:
     74             try:
---> 75                 data_list.append(future.result())
     76             except DownloadFailedException as download_exception:
     77                 if self.raise_download_errors:

~/miniconda3/lib/python3.8/concurrent/futures/_base.py in result(self, timeout)
    430                 raise CancelledError()
    431             elif self._state == FINISHED:
--> 432                 return self.__get_result()
    433 
    434             self._condition.wait(timeout)

~/miniconda3/lib/python3.8/concurrent/futures/_base.py in __get_result(self)
    386     def __get_result(self):
    387         if self._exception:
--> 388             raise self._exception
    389         else:
    390             return self._result

~/miniconda3/lib/python3.8/concurrent/futures/thread.py in run(self)
     55 
     56         try:
---> 57             result = self.fn(*self.args, **self.kwargs)
     58         except BaseException as exc:
     59             self.future.set_exception(exc)

~/miniconda3/lib/python3.8/site-packages/sentinelhub/download/client.py in _single_download(self, request, decode_data)
     98             return None
     99 
--> 100         response_content = self._execute_download(request)
    101 
    102         if request_path and request.save_response and (self.redownload or not os.path.exists(request_path)):

~/miniconda3/lib/python3.8/site-packages/sentinelhub/download/handlers.py in new_download_func(self, request)
     42         for attempt_num in range(download_attempts):
     43             try:
---> 44                 return download_func(self, request)
     45             except requests.RequestException as exception:
     46 

~/miniconda3/lib/python3.8/site-packages/sentinelhub/download/handlers.py in new_download_func(self, request)
     25                 exception.response.status_code != requests.status_codes.codes.TOO_MANY_REQUESTS:
     26 
---> 27                 raise DownloadFailedException(_create_download_failed_message(exception, request.url)) from exception
     28             raise exception from exception
     29 

DownloadFailedException: Failed to download from:
https://services.sentinel-hub.com/api/v1/process
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":"Output default requested but missing from function setup()","code":"COMMON_BAD_PAYLOAD"}}"

nevermind I think I solved it with

  responses=[
    SentinelHubRequest.output_response('s1_rtc_VV_area', MimeType.TIFF),
      SentinelHubRequest.output_response('s1_rtc_angle_mask', MimeType.TIFF)

Thank you for indicating the solution to your question, this might help other users :+1: