Skip to content

Response contains HTTP code 200 and error in body if client sends an email when disconnected from Internet #358

Closed
@ilya-chumakov

Description

@ilya-chumakov

Issue Summary

When I try to send an email without network connection to remote SMTP server, a response contains 200 OK in StatusCode and HttpRequestException in Body. I think it denies basic HTTP principles and such behaviour is completely unclear. I propose to throw a real exception. If impossible, the code from 4xx-5xx range should be used.

Steps to Reproduce

var sg = new SendGridAPIClient("my_api_key");

Mail mail = new Mail(from, subject, to, content);

//disconnect from Internet before executing this line
var response = await sg.client.mail.send.post(requestBody: mail.Get());

//writes "OK"
Console.WriteLine(response.StatusCode);

//writes ".NET HttpRequestException, raw message: An error occurred while sending the request"
Console.WriteLine(response.Body.ReadAsStringAsync().Result);

Technical details:

  • sendgrid-csharp Version: v8.0.5
  • .NET Version: 4.5.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions