question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

403Error,but i can access the link through website

See original GitHub issue

2023-01-03 13:18:41.9115|INFO|DanbooruDownloader.Commands.DumpCommand|Downloading metadata ... (5947490 ~ ) 2023-01-03 13:18:42.7698|ERROR|DanbooruDownloader.Commands.DumpCommand|System.Net.Http.HttpRequestException: Response status code does not indicate success: 403 (Forbidden). at System.Net.Http.HttpResponseMessage.EnsureSuccessStatusCode() at System.Net.Http.HttpClient.GetStringAsyncCore(HttpRequestMessage request, CancellationToken cancellationToken) at DanbooruDownloader.Utilities.DanbooruUtility.GetPosts(Int64 startId, String username, String apikey) in D:\Projects\Machine Learning Projects\DanbooruDownloader\DanbooruDownloader\Utilities\DanbooruUtility.cs:line 26 at DanbooruDownloader.Commands.DumpCommand.<>c__DisplayClass1_1.<<Run>b__0>d.MoveNext() in D:\Projects\Machine Learning Projects\DanbooruDownloader\DanbooruDownloader\Commands\DumpCommand.cs:line 49 --- End of stack trace from previous location --- at DanbooruDownloader.Utilities.TaskUtility.RunWithRetry(Func1 job, Func2 retryCondition, Int32 retryCount, Int32 retryDelay) in D:\Projects\Machine Learning Projects\DanbooruDownloader\DanbooruDownloader\Utilities\TaskUtility.cs:line 16

Issue Analytics

  • State:closed
  • Created 9 months ago
  • Comments:7

github_iconTop GitHub Comments

1reaction
AXiX-officialcommented, Jan 6, 2023

sorry,it’s my fault.I missed another changing in DanbooruDownloader/Commands/DumpCommands.cs replace:

static async Task Download(string uri, string path)
        {
            using (HttpClient client = new HttpClient())
            {
                HttpResponseMessage response = await client.GetAsync(uri, HttpCompletionOption.ResponseHeadersRead);

                switch (response.StatusCode)
                {
                    case HttpStatusCode.Forbidden:
                    case HttpStatusCode.NotFound:
                        throw new NotRetryableException();
                }

                response.EnsureSuccessStatusCode();

                using (FileStream fileStream = File.Create(path))
                {
                    using (Stream httpStream = await response.Content.ReadAsStreamAsync())
                    {
                        httpStream.CopyTo(fileStream);
                        fileStream.Flush();
                    }
                }
            }
        }

with

static async Task Download(string uri, string path)
        {
            var handler = new ClearanceHandler
            {
                MaxTries = 3,
                ClearanceDelay = 3000
            };

            using (HttpClient client = new HttpClient(handler))
            {
                HttpResponseMessage response = await client.GetAsync(uri, HttpCompletionOption.ResponseHeadersRead);

                switch (response.StatusCode)
                {
                    case HttpStatusCode.Forbidden:
                    case HttpStatusCode.NotFound:
                        throw new NotRetryableException();
                }

                response.EnsureSuccessStatusCode();

                using (FileStream fileStream = File.Create(path))
                {
                    using (Stream httpStream = await response.Content.ReadAsStreamAsync())
                    {
                        httpStream.CopyTo(fileStream);
                        fileStream.Flush();
                    }
                }
            }
        }

also remember adding

using CloudflareSolverRe;

at beginning

0reactions
PlutoNamelesscommented, Jun 14, 2023

Thank you very much, I actually about to start getting the ball rolling on this project! I would suggest making a pull request so other people wont just give up immediately like i was about to do lol

I greatly appreciate your response. However, my knowledge of C# is quite limited. I’ve tried to compile the existing code using my Visual Studio, but without any luck. I’m also stuck at the 403 step, just like you. Seeing your modifications has sparked my hope again, yet I’ve been unable to locate a compiled version in your fork, which leaves me unable to execute the code. Would you be able to provide an executable exe file that includes the fix for the 403 issue? I would be immensely grateful.

Read more comments on GitHub >

github_iconTop Results From Across the Web

403 Forbidden Error: What Is It & How To Fix It
This is a client-side error that denies you access to specific areas of a website. You might have seen it when you landed...
Read more >
What Is the 403 Forbidden Error and How to Fix It (8 ...
Can 't access a website due to the 403 Forbidden error? ... Error variations, Forbidden: You don't have permission to access [directory] on...
Read more >
How to Fix a 403 Forbidden Error on Your Site
“403 Forbidden – Access to this resource on the server is denied”; “403. That's an error. Your client does not have permission to...
Read more >
403 Forbidden error: What it is and how to fix it
It could be anything from temporary, behind-the-scenes website updates to the website being subscriber-only access. User restricted – Only ...
Read more >
What Does a 403 Forbidden Error Mean? How Do You Fix It?
This 'access is denied' error can be sometimes be corrected if ... Check for URL errors and make sure you're specifying an actual...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found