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

Replacing partial service url in batch requests with just entry name #22

Closed
dbonabalaya opened this issue Jul 21, 2021 · 2 comments
Closed

Comments

@dbonabalaya
Copy link

I have a service endpoint that looks like this: https://somedomain/service/v1

I create a batch request to post a Student entry and feeding the request to BatchRequest results in:

--batch

--changeset

POST /service/v1/Students

--changeset

--batch

Is there any workaround to make it ignore the partial service uri and instead of:

POST /service/v1/Students

create a request as:

POST Students

Thank you for your help!

@iwate
Copy link
Owner

iwate commented Jul 29, 2021

@dbonabalaya Thank you for your interest this lib.

Is there any workaround to make it ignore the partial service uri

Sorry, No, it isn't. Because HttpRequestMessage change string uri of param to System.Uri. If we set not full url, it throw UriFormatException.

var message = new HttpRequestMessage(Method, Uri);

We need to set full url like as :

var batch = new BatchRequest($"{endpoint}/$batch")
{
Requests =
{
Request.Post($"{endpoint}/Products", new
{
ID = 100,
Name = "Test Product",
Description = "Test Item",

If your odata service which is made by Microsoft.AspNetCore.OData, you also use http://localhost/service/v1/Students like as :

https://github.com/commerble/ODatalizer/blob/f61de6d0a2ca7204f246c9417bdf6d5933967a78/src/ODatalizer.EFCore.Tests/BatchTest.cs#L41-L53

@iwate iwate closed this as completed Jul 29, 2021
@iwate iwate reopened this Jul 29, 2021
@dbonabalaya
Copy link
Author

Thanks for replying to my question @iwate .

I ended up doing a bit of RegExp magic just before sending the request and removed the partial Url there.

So far so good.

@iwate iwate closed this as completed Aug 30, 2021
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

2 participants