Closed btbensoft closed 4 years ago
Hello @btbensoft,
For post something with customer header and timeout you have to to do like this :
var responseEmail = await client.PostRequest(uriPath)
.WithOAuthBearer(_adminToken) // <=== DO NOT EXIST
.WithTimeout(TimeSpan.FromSeconds(TIMEOUT_SEC)) // <=== DO NOT EXIST
.AddContent(myObject)
.ExecuteAsync<object>();
When you defined content, the API remove lot of functionalities to disable the posibility to write inconsistent request. like below :
var responseEmail = await client.PostRequest(uriPath)
.GetRequest().
.ExecuteAsync<object>();
I will rework the way to restrict methods available after you define a content to have something more usable. :)
If you want help to implement it, I also open for all pullRequests.
I don't know how solve it actually. I have define an interface IRequest : https://github.com/jgiacomini/Tiny.RestClient/blob/develop/Tiny.RestClient/Request/IRequest.cs
When you set a content on your request I restrict methods available by using the IParameterRequest. I want to prevent developer add 2 contents like this :
var aa= await client.PostRequest(uriPath)
.PostRequest().
.AddContent<object>(object)
.AddContent<object>(object)
.ExecuteAsync();
I don't know how to solve this API design issue haha
OK I found the way to do it. It will be available in the next release !
Hello,
First at all thank you for this RestClient i love it.
I got some question for you i didnt find same methods form GET or POST, specially for the bearer authentication
GET Version
POST VERSION
I think i should use like this :
.AddHeader("Authorization", "Bearer " + _adminToken)
?and how add timeout parameter?
Thanks