-
-
Notifications
You must be signed in to change notification settings - Fork 760
[BUG] URL path must start with '/' and be of the form '/foo/bar/baz' #1105
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
Comments
Are you sure that your way of building url is correct? It doesn't make sense |
Yup I'm positive. The Microsoft Dynamics Web Api is using OData. |
@arty1901's answer looks correct.... can you please explain why that won't work? |
I am trying to make a generic class for this, so I would not want to include "contacts" in the route. I submitted a very simple PR to rectify this: |
What is the value in having this completely generic? Like why not have [Get("/contacts({key})")]
Task<T> GetContacts(Key key);
[Get("/sales({key})")]
Task<T> GetSales(Key key); Or use two different interfaces, The design here looks strange. |
I got this design straight from the refit docs: The only difference is, I do not want to be forced to include a leading slash "/". There are ~100 different entities in Dynamics, so rather than writing hundreds of different methods to perform simple CRUD operations, having a generic service for this seems like the better approach. I am currently using the multiple service approach but feel it's a lot of wasted time and effort when a single generic class can do it all. My proposed change simply allows bypassing of the arbitrary enforcement of the leading slash.
|
@mjfara I would recommend using a custom delegating HttpHandler that can rewrite the URLs that you need. We're not going to be changing this behavior at this time. |
Hmm, a custom delegating HttpHandler that removes the forced leading slash is pretty hacky when compared to including an option to override the arbitrary enforcement to begin with. It wouldn't be a change of behavior, but rather an option in the RefitSettings, the default does not change. Not sure why this isn't being considered seeing as it cleanly resolves this issue. I do appreciate the workaround, but feels hacky to be doing some string substitution on the url. I guess I'll stick with my forked repo for now. |
Interessante |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Is this enforced for any reason?
I have a particular case where I do not want to start the url with a '/'
For instance, take this generic Get:
My base address is something like:
mysite.com/contacts
And I would like the attribute to simply append an id in brackets (123-456-789), resulting in:
mysite.com/contacts(123-456-789)
Any way to hack around this?
The text was updated successfully, but these errors were encountered: