How do I authenticate an API request in c#?

I want my c# program to check whether or not a player can be traded with.
This is my code:

var client = new WebClient();
var link = client.DownloadString("https://trades.roblox.com/v1/users/1/can-trade-with");

This is the error I get when I run the program: The remote server returned an error: (401) Unauthorized.

I know that I need to authenticate my API request but how do I do that?

Any help is appreciated!

2 Likes

Roblox platform uses Luau, a variant of Lua 5.1. We don’t use C#, so this is technically off-topic.

That said, it looks like whatever request you’re making probably isn’t sending the auth cookie, which might be required for that endpoint.

2 Likes

easy.

add X-CRSF-TOKEN to headers,
add Cookie ,
fin.

2 Likes