Custom Requests - Thundermaker300/RoSharp GitHub Wiki

The following creates a HttpMessage to use in a custom request.

HttpMessage message = new(HTTP_METHOD_HERE, "URL_HERE", BODY_HERE)

The below code sample shows how to create a custom request to the website using RoSharp's HttpManager API.

Session session = new();
await session.LoginAsync(".ROBLOSECURITY_CODE_HERE");

HttpMessage message = new(HttpMethod.Get, "https://www.roblox.com");
HttpResponseMessage response = await HttpManager.SendAsync(sesh, message);
Console.WriteLine(await response.Content.ReadAsStringAsync());

Sessions are optional and can be null. If the session is null, the assigned global session will be used if assigned. Otherwise, no authentication will be sent.

Retry behavior

By default, every request type through the HttpManager (except for GET) is sent twice. The first time is purely to obtain the X-CSRF-TOKEN if not already available. This token refreshes every couple of minutes but can be obtained from any HTTP request, and is required to perform any non-GET operations on the website. Any other data from the first request is discarded, and a second request (containing the new X-CSRF-TOKEN) is sent. This is the response that is seen.