Get glitch response from c# client

hello. i am hosting an asp.net core .net 6 webapi on glitch it does a very simple work which is return client ip address and is a test project. It is working perfectly fine in browser but i want to use it as an api for my unity game so the server need to called from c# client.

Now the problem is, that when i call the server from c# client with this code -

HttpClient client = new HttpClient();
string response = await client.GetStringAsync(url);
System.Console.WriteLine(response);

i get a 403(forbidden) error.

Alternatively, when i try to access it with this code -

HttpClient client = new HttpClient();
string response = await (await client.GetAsync(url)).Content.ReadAsStringAsync();
System.Console.WriteLine(response);

i get the html code of the waking up page of glitch.

i also tried to use the websocket client method in c# client but it is not working too…

Kindly help. Plz share the solution and if you can code too, or if you can give the link to solution webpage.

Sorry for any grammatical mistakes.

1 Like

also i have not shared my project link because sharing it is of no use… i only upload self-contained linux-x64 published project to glitch because it runs without any problem this way so my glitch project doesn’t have any human readable code in it.

1 Like

i get the html code of the waking up page of glitch.

Glitch takes some time to load, you probably need to open the project’s URL and then do the request to see the code. Oh, and welcome, @PY15208! :hugs:

@_tr
hello and thanks for response. i dont think there is any library in c# which allows to do that. I dont know why but adding the user-agent header in httpclient helped.

For anyone who encounters this problem in future, I asked this answer on stackoverflow where the actual solution is: node.js - glitch.com project can't be called with c# - Stack Overflow

2 Likes

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.