menu_bookDocumentation
HTTP Requests: Async GET and POST with JSON in s&box
s&box provides a static Http class for asynchronous HTTP requests (GET, POST, DELETE, etc.) with JSON support.
Allowed URLs
Only http or https URLs to domains (no IP addresses). localhost is permitted only on ports 80/443/8080/8443. Use the -allowlocalhttp command line switch to access any local URL from the server.
Common Patterns
CSHARP
// GET request returning response as string
string response = await Http.RequestStringAsync( "https://google.com" );
// POST JSON content, ignoring response
await Http.RequestAsync( "https://api.facepunch.com/my/method", "POST", Http.CreateJsonContent( playerData ) );The Http.CreateJsonContent() helper serializes an object to JSON for POST/PUT requests. All requests are asynchronous and should be awaited.
Was this helpful?