Reputation: 533
Im trying to access an API from ESA. details here when using curl,
curl -svgu <user>:<password> "https://scihub.esa.int/dhus/odata/v1/Products?$filter=year(IngestionDate) eq 2015 and month(IngestionDate) eq 10 and day(IngestionDate) eq 10"
The responde comes with wrong dates (2014)
Using the same link, on chrome, yields the expected result (files with the date passed)
https://scihub.esa.int/dhus/odata/v1/Products?$filter=year(IngestionDate) eq 2015 and month(IngestionDate) eq 10 and day(IngestionDate) eq 10
I tried to remove spaces and use
`"https://scihub.esa.int/dhus/odata/v1/Products?$filter=year(IngestionDate)%20eq%202015%20and%20month(IngestionDate)%20eq%2010%20and%20day(IngestionDate)%20eq%2010"`
on curl.
Any suggestions or ideas? You can use those links to try.
EDIT: Per suggestion of Pafjo, curl -G -gu : "https://scihub.esa.int/dhus/odata/v1/Products" --data-urlencode '$filter=year(IngestionDate) eq '"$YEAR and month(IngestionDate) eq $MONTH and day(IngestionDate) eq $DAY" this is the answer
Upvotes: 0
Views: 1075
Reputation: 5019
Curl does not url encode your url so you need to tell it what part that should be url-encoded.
Try this and see if you the correct response:
curl -G -svgu <user>:<password> "https://scihub.esa.int/dhus/odata/v1/Products" --data-urlencode '$filter=year(IngestionDate) eq 2015 and month(IngestionDate) eq 10 and day(IngestionDate) eq 10'
The reason that your second curl command failed is that you have $filter inside double quotes. So when you do the request the shell will replace your variables with values. This is fixed by using single quotes or escaping the dollar sign.
Upvotes: 1
Reputation: 374
Upvotes: 0