CASE RestMethod OF 'PATCH': BEGIN String := 'PATCH' //it's a DotNet String variable HttpRequestMessage.Content(HttpContent); //HttpContent contains JSON object which I sent HttpRequestMessage.Method(String); //I've tried to use ('PATCH') instead of String, but it requires DotNet variable HttpResponseMessage := HttpClient.SendAsync(HttpRequestMessage); END; END;
Unfortunately that didn't help.A call to System.Uri failed with this message: Invalid URI: The format of the URI could not be determined.
Is there any possibility to lookup how is, for example HttpClient.PutAsync method built?
I feel like I'm giving up, and maybe I could just use this PATCH method with REST Sharp library, that you have recommended..
MethodUri := MethodUri.Uri(BaseUrl + Method);And, naturally, make sure that either your BaseUrl ends with, or Method begins, with a slash
Answers
Thank you for your answer, but unfortunately I've already tried that.
There is no such method as Patch - and that's the problem. There are methods like Get, Put and Post.
My code is inspired by this topic (hopefuly it's not a problem to link something from outside of this forum):
Patch_method_AL
You should try then (should work in theory):
Alternatively, you could go with RestSharp library.
I think, that I know what's the reason, but I don't know how to fix the problem.
I will show you my entire code, so I can explain:
And maybe a little explanation here, RestMethod, as you can see is GET, POST, PUT, DELETE or PATCH. Also there is a Method (query) that I can use with API, for example 'api/employees' and I can combine that with different queries.
As you can see, HttpClient.Get/Post/Put/Delete methods takes this Method as a parameter, so now I don't know where to put this Method variable, so it could work with newly defined PATCH case.
I have tried something like: but it doesn't work and results with following error:
Do you have any idea how to fix that?
Sorry I can't test these things, don't have a proper platform with PATCH methods
The thing is, that the method RequestUri requires a DotNet parameter, while my Method is a text.
I've just tried to do that the same way as before, so I added two lines: But it doesn't seem to work and results with an error:
Is there any possibility to lookup how is, for example HttpClient.PutAsync method built?
I feel like I'm giving up, and maybe I could just use this PATCH method with REST Sharp library, that you have recommended..
Oh, looks like System.Uri needs absolute path, aka And, naturally, make sure that either your BaseUrl ends with, or Method begins, with a slash
That works!
Thank you so much for helping me!