Search code examples
curlodata

Curl and Odata filter: Invalid filter expression


I need to apply a OData filter in a curl request like this one

curl -k -H "Authorization: Bearer d_fkI7fEPSz9z8RmaGklFWeuPp4a" -v 'https://api.smartdatanet.it/api/Deploy_confi_3790/DataEntities?&$format=json&$top=15&$filter=Ide_id eq 2071)'

The service respond in Json format like this one

            "internalId": "5c50c7e97f3a377c2431e8cf",
            "datasetVersion": 1,
            "idDataset": "3790",
            "Id_unita_install": 52709,
            "Progressivo": "2",
            "Tipo_udd": "Unità di config",
            "Id_istanza": 1347,
            "Id_middleware": 4,
            "Middleware": "Apache WebServer",
            "Vers_middleware": "2.2.31",
            "Ambiente": "COLL",
            "Partizione": null,
            "Dominio": null,
            "Valore": "naocli/naocli8",
            "Ide_id": 2071

... so the Ide_id field exist and has numbers inside.

When I try to execute the error is:

{"error":{"code":null,"message":{"lang":"en","value":"Invalid filter expression: 'Ide_id'."}}}

Any suggestions is appreciated!


Solution

  • I've solved! There are two errors in my original curl request, a sintax error ( the ")" at the end of the request ....), and some troubles not using escape for "spaces" in the filter.

    The right request is the follow

    curl -k -H "Authorization: Bearer d_fkI7fEPSz9z8RmaGklFWeuPp4a" -v 'https://api.smartdatanet.it/api/Deploy_confi_3790/DataEntities?&$format=json&$top=15&$filter=Ide_id%20eq%202290'