Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

URL encoding? #126

Open
baradhili opened this issue Mar 6, 2023 · 0 comments
Open

URL encoding? #126

baradhili opened this issue Mar 6, 2023 · 0 comments

Comments

@baradhili
Copy link

my code:

$filterEarliest = urlencode('2000-02-05T08:48:36+08:00');
        $filterLatest = urlencode('2023-03-05T08:48:36+08:00');
        $domainKey = urlencode('h');

$result = $odataClient->from('ProductSearch')
            ->where('UpdatedAt','>=',$filterEarliest)
            ->where('UpdatedAt','<=',$filterLatest)
            ->where('domainKey','=','h')
            ->expand('activeSubstances,atcCodes,doseForms,rms')
            ->skip(0)
            ->take(10)
            ->get();

generates a URL of
https://mri.cts-mrp.eu/portal/v1/odata/ProductSearch?$filter=UpdatedAt%20ge%202000-02-05T08%3A48%3A36%2B08%3A00%20and%20UpdatedAt%20le%202023-03-05T08%3A48%3A36%2B08%3A00%20and%20domainKey%20eq%20%27h%27&$expand=activeSubstances,atcCodes,doseForms,rms&$skip=0&$top=10

this results in an error from the server
"The query specified in the URI is not valid. A binary operator with incompatible types was detected. Found operand types 'Edm.DateTimeOffset' and 'Edm.String' for operator kind 'GreaterThanOrEqual'."

The server is actually expecting
https://mri.cts-mrp.eu/portal/v1/odata/ProductSearch?$filter=UpdatedAt%20ge%202022-12-27T18%3A54%3A09%2B08%3A00%20and%20UpdatedAt%20le%202023-01-27T18%3A54%3A09%2B08%3A00%20and%20domainKey%20eq%20%27h%27&$expand=activeSubstances,atcCodes,doseForms,rms&$count=true&$skip=10&$top=10

It appears it wants the dates URL encoded and not surrounded by single quotes (')

Any suggestions? - it would be nice not to need to urlencode the dates in my code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant