Common_bad_payload

I’m using get_s2_evalscript from s2cloudless to get images from s2-L1C

Here is how I do it in Python

        
        evalscript = get_s2_evalscript(
            all_bands=True,
            reflectance=True
        )

And the output looks like the following;

//VERSION=3
function setup() {
  return {
    input: [{
      bands: ["B01", "B02", "B03", "B04", "B05", "B06", "B07", "B08", "B8A", "B09", "B10", "B11", "B12", "dataMask"],
      units: "reflectance"
    }],
    output: {
      id: "bands",
      bands: 14,
      sampleType: "FLOAT32"
    }
  };
}

function evaluatePixel(sample) {
  return [sample.B01, sample.B02, sample.B03, sample.B04, sample.B05, sample.B06, sample.B07, sample.B08, sample.B8A, sample.B09, sample.B10, sample.B11, sample.B12, sample.dataMask];
} 

But when I run the following

wcs_img = sh_request.get_data(save_data=True)

I get the following error

400 Client Error: Bad Request for url: https://services.sentinel-hub.com/api/v1/process
Server response: "{"status": 400, "reason": "Bad Request", "message": "Output default requested but missing from function setup()", "code": "COMMON_BAD_PAYLOAD"}"

My code used to run perfectly fine today Morning and all of a sudden it starts to complain about setup() function.

Any idea how to solve this?

Thanks a lot

Hi @Basbabudel,

It is possible that the responses in your payload are not correctly set. An example:

responses=[SentinelHubRequest.output_response("default", MimeType.TIFF)],

This works if the output in your function setup() has no specific id, because it uses “default” in that case (see documentation).

However, you provide an output id (“bands”) in your function setup():

output: {
      id: "bands",
      bands: 14,
      sampleType: "FLOAT32"
    }

You can either delete the id: "bands" from your evalscript, or adjust the output id in the responses from “default” to “bands”.

Note that setting an output id is necessary for multiple responses, as the returns have to be uniquely identifiable by the service.

Awesome, Works just perfectly. It used to work with the “default” param. Wondering if there has been a change in APIs!

Thanks @max.kampen

There were no changes to the API that would affect this part of the requests. Maybe you tried running the request before setting id: "bands" in the output.