« first day (4017 days earlier)      last day (924 days later) » 

 
2 hours later…
7:13 AM
GoOoOoOoOoOoOoOoOoOoOoOd Mornin' neglecterinos!
 
8:04 AM
[Captain Obvious] Morning
 
Good morning
 
 
1 hour later…
9:27 AM
@Ben are you stucc since 2018?
 
mr5
9:39 AM
help step wietlol, Ben is stuccc
 
10:01 AM
 
 
1 hour later…
11:10 AM
@mr5 I had to go home a few minutes after that....tryna pick up where I left off, but I think I'm getting somewhere now
like httpwebrequest.address is a thing
 
11:26 AM
now I'm just trying to figure out this "stream was not writable" response
 
mr5
you probably dispose it somewhere else already
are you using a raw HttpClient?
 
aw wait I found out why it was saying that
        using (var streamWriter = new StreamWriter(request.GetRequestStream()))
        {
            var json = JsonConvert.SerializeObject(r);
            streamWriter.Write(json); // writes data to request
        }
thas what I'm doing
nvm the "not writable" thing; I'm just blind
now I'm just getting problems at var response = (HttpWebResponse)request.GetResponse()
 
mr5
are you still using the depcrecated WebRequest?
I think there is a JsonConvert.SerializeObject overload that accepts stream as input
 
guess so
`var request = (HttpWebRequest)WebRequest.Create(
string.Format("http://www.duh.com"));`
 
mr5
so you don't need that StreamWriter
 
11:40 AM
I"m using that here
oh
@mr5 what do I use if I don't use the streamwriter?
 
mr5
just pass the stream object directly
var json = JsonConvert.SerializeObject(request.GetRequestStream());
for disposing the stream, I'm not sure when
hmm
 
OH
 
mr5
shouldn't it be response not request?
oh you are making a request
 
I wanna get the response after initiating the request
if (response.StatusCode != HttpStatusCode.Unauthorized) // otherwise throws exception
                {
                    using (var streamReader = new StreamReader(response.GetResponseStream()))
                    {
                        var result = streamReader.ReadToEnd();
                        returnedJSON = result.ToString();
                        tranResult = JsonConvert.DeserializeObject<RtgsResult.RoutingResultWrapper>(returnedJSON).Data;
                    }
                }
I have a wrapper class that needs to be serialized; that's what the (r) in JsonConvert.SerializeObject(r) is.
so I think I do need the streamwriter
 
mr5
You actually don't
 
11:53 AM
what am I supposed to put the wrapper in?
 
mr5
Probably if you're using also a deprecated version of Newtonsoft JSON
just pass the stream
remove all this redundant StreamWriter
 
newtonsoft 13.0.1 is the newest one
 
mr5
it's already implemented in the Newtonsoft library
@Freerey oh my bad
I got confused by HttpClient. You need StreamWriter.
 
I must be passing the wrapper in wrong if the request address doesn't contain any of the parameters
 
mr5
what Content-Type is the server specifically expecting though?
 
12:05 PM
applicaton/json
 
mr5
err
I mean the body type. Is it form-data, x-www-form-urlencoded, or raw (StringContent), or binary?
 
x-www-form-urlencoded
 
mr5
Are you using FormUrlEncodedContent?
it seems you're using a raw there.
 
nope
 
mr5
but I am not that familiar with WebRequest
If you're using HttpClient, I can help you better
or much better yet, just use this: github.com/restsharp/RestSharp
 
12:20 PM
I should port Khttp to .net...
then we would finally have a sane http library
 
mr5
I think RestSharp is decent enough
problem is, it resolves everything at compile time
 
Same for RestEase, same thing basically. Anyone got a good comparison? Haven't used RestSharp yet.
 
@mr5 it what?
 
mr5
the interface
Like that one on Volley
 
its an http client...
 
mr5
12:27 PM
(Java library)
 
oh
Ok then not same for RestEase
 
mr5
[Get("relative/path/here")]
Task<T> GetUser([Param]int id);
 
RestEase is great as it completely encapsulates the HTTP stuff. What you get is something implementing an interface you define, adding routes to the interface methods, and you just call the method.
 
@mr5 that's for .net core
 
mr5
I'm referring to those http client library like this^
 
12:29 PM
ew
 
mr5
@Freerey oh, migrate to .netcore then
 
-throttles finn-
 
Migration isn't always an option
 
mr5
@Squirrelkiller yeah, that's basically what RestClient does (C#)
 
Still better use HttpClient it's a nice abstraction
 
mr5
12:31 PM
RestSharp is just a copy of the popular Java lib (forgot it's name)
 
Also MS has a package with extensions adding json support for your convenience.
 
"HttpClient" and "nice" shouldnt be used in the same sentence
 
They absolutely should
Look at this very nice call
 
not in the way how they handle
- the interfacing
- the method signatures
- headers
- content headers
- base path
- input content
 
Although I think I added the Deserialize method myself to wrap around a Task without having to put (await (await Call()).Deserialize()))
 
12:35 PM
I end up always having to write some helper functions for HttpClient
and avoid using any of the bonus "features" it has
 
See, without avoiding those feature you could probably use it without writing helper functions
 
nope
 
Right
||wietlol2
 
Sep 13 '17 at 15:07, by Wietlol
i will most probably write my own
 
for example, the base address
"https://stackexchange.com/api/stackoverflow"
(imagine that is a real address)
that is a wrong base address because a base address can only be the domain name, not the rest of the path
 
12:38 PM
Nah
It's not Host
 
yes
 
BaseAddress is whatever is the base for the call you intent to make
So if you're gonna make calls to a few endpoints where it always starts with "https://stackexchange.com/api/stackoverflow", that is the base for all the following calls
If you make calls to multiple sites, maybe your base doesn't include /stackoverflow
 
I don't think httpclient is supported by my version of .net
 
If you wanna get several questions, maybe your base additionally includes /questions
 
new HttpClient
{
    BaseAddress = new Uri("https://stackexchange.com/api/stackoverflow/")
}.GetAsync("ping");
// sends request to stackexchange.com/ping
 
12:41 PM
@Freerey It's a nuget package for older versions
 
mr5
@Wietlol iirc, you have to remove the trailing / for base address for the relative path to append properly
 
4.5, that's what I got
 
mr5
then you have to figure out what "body type" your WebRequest is forming
 
Ouchy
 
mr5
Maybe you can check on the server side if you have access?
 
12:45 PM
We were on 4.5 for quite some time, HttpClient definitely works as a nuget package.
 
I know i have access because when I put the api through postman, it actually works
 
mr5
I mean, access to debug the server
 
I always have to write the wrappers to be able to have headers with my request
 
Because this is too hard to do?
 
those are default headers
I want the headers only for one request
not for all of them
 
12:55 PM
@Squirrelkiller MIcrosoft.Extensions.Http?
yyyep looks like that
 
Interesting, I think we used Microsoft.Net.Http
Extensions probably delivers said json helper functions
 
mr5
@Wietlol that is why I created my own HttpService before
cuz I encounter that necessity a lot before
fakkk
T1 lost :(
 
mr5
1:32 PM
@Squirrelkiller that's acually pretty bad
DefaultRequestHeaders behaves inconsistently
 
[Captain Obvious] YOU WANT INCONSISTENCY
[Captain Obvious] TRY HANDLING MS GRAPH ERRORS
 
@mr5 It's actually this now:
 
mr5
my DNS (or probably ISP) is pretty fucked up. imgur.com is blocked apparently
 
By ISP?!
 
mr5
1:36 PM
dunno lol
so I have to use a proxy to view something from imgur
 
[Captain Obvious] Try using a different DNS provider like cloudflare (1.1.1.1) or googler (8.8.8.8)
[Captain Obvious] And then if that dont work then yeah your ISP is shit
 
mr5
it's also behaving inconsistently
everything is inconsistent these days
was about to issue a flushdns command but it seems changing my main DNS to 1.1.1.1 fixes it
thanks @CaptainObvious!
 
[Captain Obvious] Welcome
 
 
5 hours later…
6:35 PM
@TravisJ Thanks!
 
there is about 90x more yelling when I'm programming at home vs in my office
 
7:12 PM
hey you guys do you know anything about msbuild?
 
mr5
mv /path/to/source.extension /path/to/destination/.
 
<FilesForPackagingFromProject Include="..\aipackagefiles\*.ini">
<DestinationRelativePath>\$(RecursiveDir)%(FileName)%(Extension)</DestinationRelativePath>
</FilesForPackagingFromProject>
something thats what i have but its wrong...its in the publish profile
 
8:03 PM
 

« first day (4017 days earlier)      last day (924 days later) »