Tuesday 16 May 2017

UI5 oData Gotcha...


Sending a request to my oData service with 2 filter parameters (Postcode and Distance)

/sap/opu/odata/sap/YPD_PL1_SRV/OTabset?$filter=Postcode eq 'TQ8 8JT' and Distance eq '10'

was yielding me the following error:

<message xml:lang="en">Invalid parametertype used at function 'eq' (Position: 36)</message>

And the problem was... since my SEGW declaration of Distance was Edm.Decimal the interface gets a bit pissy that it's being asked to look at something in single-quotes...

So the fix is, remove the single quotes on that variable - 

Now we have:

/sap/opu/odata/sap/YPD_PL1_SRV/OTabset?$filter=Postcode eq 'TQ8 8JT' and Distance eq 10

and this yields my beautiful oData:


Yay! Simple mistake, but I couldn't find it when Googling for Invalid ParameterType and it took me a while to spot, so hopefully helpful to someone out there.