Curl API problem

I am trying to use the curl API for the first tile and am getting an error. I successfully set up my oauth credentials and can get a token, but when I try to run this example it does not work:

https://docs.sentinel-hub.com/api/latest/data/sentinel-2-l2a/examples/#other-s2l2a-specific-data-aerosol-optical-thickness-scene-classification-snow-and-cloud-probabilities-sun-and-view-angles

I have double checked my curl command and it is implemented exactly like the example as far as I can tell (with my token inserted), but I get this error:

{“error”:{“status”:400,“reason”:“Bad Request”,“message”:“Script contains no code to execute.”,“code”:“RENDERER_EXCEPTION”}}

Any ideas what could be wrong? Can others successfully run the example?

Thanks…

-M

Hi @mfestuary, It’s difficult to offer a precise solution without examining the curl request you’re attempting to make. I recommend utilizing the Request Builder for assistance. After logging in, paste your curl request into the Request Preview and click on the ‘Parse’ button to streamline the process. It will automatically fix any issue you could be having when editing the example. Let me know if then you can successfully run it.

I also tried a simpler example that gives the same problem. Here is the exact curl command (except that I have truncated the token string with ellipsis(…):

curl -X POST https://services.sentinel-hub.com/api/v1/process -H ‘Authorization: Bearer eyJraWQiOiJz…’ -F ‘request={ “input”: { “bounds”: { “properties”: { “crs”: “http://www.opengis.net/def/crs/OGC/1.3/CRS84” }, “bbox”: [ 13.822174072265625, 45.85080395917834, 14.55963134765625, 46.29191774991382 ] }, “data”: [ { “type”: “sentinel-2-l2a”, “dataFilter”: { “timeRange”: { “from”: “2022-09-01T00:00:00Z”, “to”: “2022-09-30T00:00:00Z” } } } ] }, “output”: { “width”: 512, “height”: 512 } }’ -F ‘evalscript=//VERSION=3 function setup() { return{ input: [“B02”, “B03”, “B04”], output: { bands: 3, sampleType: “AUTO” } } } function evaluatePixel(sample) { return [sample.B04, sample.B03, sample.B02] }’

You are having an issue when copying the examples. In this case you are using the wrong quotes, instead of curly single quotes ( ‘ ) you should use straight single quotes ( ’ ), like the ones that are in the examples.

Here is a fixed version of your curl.

curl -X POST https://services.sentinel-hub.com/api/v1/process -H 'Authorization: Bearer eyJraWQiOiJz…' -F 'request={ "input": { "bounds": { "properties": { "crs": "http://www.opengis.net/def/crs/OGC/1.3/CRS84" }, "bbox": [ 13.822174072265625, 45.85080395917834, 14.55963134765625, 46.29191774991382 ] }, "data": [ { "type": "sentinel-2-l2a", "dataFilter": { "timeRange": { "from": "2022-09-01T00:00:00Z", "to": "2022-09-30T00:00:00Z" } } } ] }, "output": { "width": 512, "height": 512 } }' -F 'evalscript=//VERSION=3 function setup() { return{ input: ["B02", "B03", "B04"], output: { bands: 3, sampleType: "AUTO" } } } function evaluatePixel(sample) { return [sample.B04, sample.B03, sample.B02] }'

Please after fixing the quotes try with the Request Builder to parse it.

I copy and pasted your version into the requests builder and it seemed to parse correctly. However, it made a subtle chang from form submission (-F) to data submission (-d). After it was parsed I hit the send button, bit I got a message that says “Script contains no code to execute”.

Yes, you are right. My version was just the code you sent but with the fix of the quotes, there is an other issue related with some spaces in the Evalscript. Here is a version you can parse and make it work

curl -X POST https://services.sentinel-hub.com/api/v1/process \
 -H 'Content-Type: application/json' \
 -H 'Authorization: Bearer eyJr... \
 -d '{
  "input": {
    "bounds": {
      "bbox": [
        13.822174072265625,
        45.85080395917834,
        14.55963134765625,
        46.29191774991382
      ]
    },
    "data": [
      {
        "dataFilter": {
          "timeRange": {
            "from": "2022-10-01T00:00:00Z",
            "to": "2022-10-31T00:00:00Z"
          }
        },
        "type": "sentinel-2-l2a"
      }
    ]
  },
  "output": {
    "width": 512,
    "height": 512,
    "responses": [
      {
        "identifier": "default",
        "format": {
          "type": "image/jpeg"
        }
      }
    ]
  },
  "evalscript": "//VERSION=3\n\nfunction setup() {\n  return {\n    input: [\"B02\", \"B03\", \"B04\"],\n    output: {\n      bands: 3,\n      sampleType: \"AUTO\" // default value - scales the output values from [0,1] to [0,255].\n    }\n  }\n}\n\nfunction evaluatePixel(sample) {\n  return [2.5 * sample.B04, 2.5 * sample.B03, 2.5 * sample.B02]\n}"
}'

In general if you copy and paste any of the examples from the site Examples for S2L2A into the Request Builder, they should be parsed with no problem. Please check the process of copying and pasting examples to avoid issues like the quotes and the spaces between the lines of code. Let me know if this works for you.

Thank you very much for your patience and the timely help!! I finally figured out the problem and got it all working.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.