Problems using $select with $expand in Priority REST API

588 views Asked by At

Using the Rest API, I'm trying to use $select with $expand like this:

https://priority.company.biz/odata/Priority/tabula.ini/company/DOCUMENTS_D?$filter=CURDATE ge 2020-01-01 and CURDATE le 2020-01-31&$expand=TRANSORDER_D_SUBFORM&$select=CUSTNAME,CDES

I get a 500 error. It seems that these two operators don't work together. I tried each one of them separately and they work. Any insights?

3

There are 3 answers

4
Lior Balmas On

try this:

subform needs to be in paranthesis and no & before subform's select

https://priority.company.biz/odata/Priority/tabula.ini/company/DOCUMENTS_D?$select=DOCNO,TYPE,CUSTNAME, CDES&$filter=CURDATE ge 2020-01-01 and CURDATE le 2020-01-31&$expand=TRANSORDER_D_SUBFORM
0
David B.E On

from which programming lang do you call the rest service ? It works Ok if you use the rest date format CURDATE eq 2020-04-28T00:00:00+00:00 when you call url with specical chars like + you must replace it for example + = %2B

from C# for example we use Uri.EscapeDataString(MyDateString) to combine the date in the URL

0
Matan Yardeni On

When combining $expand and $select features you must include in the $select parameter the key(s) of the upper-level form.

Your corrected URL:

https://priority.company.biz/odata/Priority/tabula.ini/company/DOCUMENTS_D?$filter=CURDATE ge 2020-01-01 and CURDATE le 2020-01-31&$expand=TRANSORDER_D_SUBFORM&$select=CUSTNAME,CDES,DOCNO,TYPE

Priority software added it to its documentation recently:

Note: When using the $expand command for a subform with composite keys, the $select command must include all key fields from the upper-level form

And I add: It is not only for composite keys but for all simple 'one-column' keys.