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

How to show actual URL called #157

Closed
DJDaveMark opened this issue Sep 18, 2023 · 5 comments
Closed

How to show actual URL called #157

DJDaveMark opened this issue Sep 18, 2023 · 5 comments

Comments

@DJDaveMark
Copy link

DJDaveMark commented Sep 18, 2023

How can I log the actual URL the o.js client is calling?

I have a non trivial GET request (multiple $expand, $select, $filter, $orderby etc.) which returns an error from the odata API.
When I constructed the URL with Postman, it worked fine, but in code, what should be the same thing, returns the following error which doesn't make any sense:

{
    "error": {
        "code": null,
        "message": "The types 'Edm.Boolean' and 'Edm.DateTimeOffset' are not compatible."
    }
}

I tested constructing the URL myself and passing it to the o.js client, and it works as expected.

@janhommes
Copy link
Owner

using dev tools is not an option for you? I guess you are using node.js sever to server?

Maybe you can simply add a log to the node_modules/o.js source code:
https://unpkg.com/browse/o.js@1.3.2/dist/cjs/o.js

this.url.href logging on line 80 should help.

@DJDaveMark
Copy link
Author

DJDaveMark commented Sep 21, 2023

I found out that the error is because of spaces being replaced with plus symbols:
update_date ge 2023-12-31T23:59:59.000Z

becomes:
update_date+ge+2023-12-31T23%3A59%3A59.000Z

which looks like a perfectly fine URL, but OData allows query like syntax so + is a reserved character.
The spaces need to be percent encoded:

update_date%20ge%202023-12-31T23%3A59%3A59.000Z

OData Version 4.0 Part 2: URL Conventions
https://docs.oasis-open.org/odata/odata/v4.0/os/part2-url-conventions/odata-v4.0-os-part2-url-conventions.html

Example 28: entity count in a $filter expression. Note that the spaces around gt are for readability of the example only; in real URLs they must be percent-encoded as %20.

@janhommes
Copy link
Owner

Sounds like: #129

Can you try the version 2.0.0-rc1. I guess it should be fixed there... I actually wanted to do a new release on this but missed time management ;)

@DJDaveMark
Copy link
Author

Just finished testing. Everything works great with 2.0.0-rc1.

I successfully processed 900K objects from a Denodo OData API, and the code is clean thanks to o.js 😃

Since version 2.0.0-rc1 was first published back in May 2022 (~1.5 years ago), why not just release it? If there were bugs, they should have been reported by now.

@janhommes
Copy link
Owner

yeah, as said... time management... but I just released version 2.0.0 5h ago 🥳

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

No branches or pull requests

2 participants