ruby-connect-rest-sample icon indicating copy to clipboard operation
ruby-connect-rest-sample copied to clipboard

HTTP 400 for sendMail

Open leenasn opened this issue 10 years ago • 4 comments

Hi,

While trying the app, I am getting the message as '

Something went wrong, couldn't send an email. 400 - Bad Request

Below is the screenshot of the same. Can someone help me fix it?

Thanks, Leena

screen shot 2016-07-27 at 4 50 38 pm

leenasn avatar Jul 27 '16 11:07 leenasn

Hi @leenasn,

I'm sorry you're having problems with this sample. I can look at your issue.

Unfortunately, I can't repro the issue you're experimenting. Could you provide the following information?

  • Operating system
  • Ruby version with ruby --version
  • Any other relevant information displayed on the console

Also, make sure that you register your app in the same tenant that you use in the environment.rb file and you're trying the sample with a user from that same tenant.

Thank you

ricalo avatar Aug 04 '16 17:08 ricalo

Hi,

I am sharing the log with you. The tokens are MASKED:

I, [2016-08-11T18:05:48.867285 #57550] INFO -- : Started POST "/auth/azureactivedirectory/callback" for ::1 at 2016-08-11 18:05:48 +0530 I, [2016-08-11T18:05:48.869015 #57550] INFO -- omniauth: (azureactivedirectory) Callback phase initiated. I, [2016-08-11T18:05:49.435828 #57550] INFO -- : Processing by PagesController#callback as HTML I, [2016-08-11T18:05:49.435958 #57550] INFO -- : Parameters: {"code"=>"######MASKED######"} V, [2016-08-11T18:05:49.436472 #57550] VERBOSE -- ###MASKED###: TokenRequest getting token with authorization code ###MASKED###, redirect_uri http://localhost:3000/auth/azureactivedirectory/callback and resource https://graph.microsoft.com. V, [2016-08-11T18:05:49.436734 #57550] VERBOSE -- ###MASKED###: TokenRequest checking cache #ADAL::MemoryCache:0x007fdabec5b958 for token. V, [2016-08-11T18:05:49.436846 #57550] VERBOSE -- ###MASKED###: Searching cache for tokens by keys: [:authority, :client_id]. V, [2016-08-11T18:05:49.436887 #57550] VERBOSE -- ###MASKED###: Validating 0 possible cache matches. V, [2016-08-11T18:05:49.436917 #57550] VERBOSE -- ###MASKED###: Looking through 0 matching cache entries for resource https://graph.microsoft.com. V, [2016-08-11T18:05:49.436942 #57550] VERBOSE -- ###MASKED###: Attempting to obtain access token for https://graph.microsoft.com by refreshing 1 of 0 matching MRRTs. I, [2016-08-11T18:05:49.437022 #57550] INFO -- ###MASKED###: Did not find token in cache. V, [2016-08-11T18:05:49.437088 #57550] VERBOSE -- ###MASKED###: Resorting to OAuth to fulfill token request. V, [2016-08-11T18:05:51.412110 #57550] VERBOSE -- ###MASKED###: Attempting to create a TokenResponse from raw response. W, [2016-08-11T18:05:51.412294 #57550] WARN -- ###MASKED###: No id token found. I, [2016-08-11T18:05:51.412421 #57550] INFO -- ###MASKED###: Parsed a SuccessResponse with access token digest ###MASKED### V, [2016-08-11T18:05:51.412528 #57550] VERBOSE -- ###MASKED###: Adding successful TokenResponse to cache. V, [2016-08-11T18:05:51.412656 #57550] VERBOSE -- ###MASKED###: Added 1 new entries to cache. I, [2016-08-11T18:05:51.412802 #57550] INFO -- : Code: ###MASKED### I, [2016-08-11T18:05:51.412850 #57550] INFO -- : Name: Leena N I, [2016-08-11T18:05:51.412872 #57550] INFO -- : Email: [email protected] I, [2016-08-11T18:05:51.412900 #57550] INFO -- : [callback] - Access token: ###MASKED### I, [2016-08-11T18:05:51.420261 #57550] INFO -- : Rendered pages/callback.html.erb within layouts/application (1.5ms) I, [2016-08-11T18:05:51.423467 #57550] INFO -- : Completed 200 OK in 1987ms (Views: 10.3ms | ActiveRecord: 0.0ms) ::1 - - [11/Aug/2016:18:05:51 +0530] "POST /auth/azureactivedirectory/callback HTTP/1.1" 200 - 2.5657 D, [2016-08-11T18:05:54.380355 #57550] DEBUG -- : D, [2016-08-11T18:05:54.380402 #57550] DEBUG -- : I, [2016-08-11T18:05:54.380470 #57550] INFO -- : Started POST "/send_mail" for ::1 at 2016-08-11 18:05:54 +0530 I, [2016-08-11T18:05:54.381832 #57550] INFO -- : Processing by PagesController#send_mail as HTML I, [2016-08-11T18:05:54.381870 #57550] INFO -- : Parameters: {"specified_email"=>"[email protected]"} D, [2016-08-11T18:05:54.382359 #57550] DEBUG -- : [send_mail] - Access token: ###MASKED### D, [2016-08-11T18:05:54.383277 #57550] DEBUG -- :

Congratulations Leena N,

This is a message from the Microsoft Graph Connect Sample. You are well on your way to incorporating Microsoft Graph endpoints in your apps.

What’s next?

  • Check out dev.office.com to start building Microsoft Graph and Office 365 apps today with all the latest tools, templates, and guidance to get started quickly.
  • Head over to the Microsoft Graph reference on MSDN to explore the rest of the APIs.
  • Browse other samples on GitHub to see more of the APIs in action.

Give us feedback

  • If you have any trouble running this sample, please log an issue.
  • For general questions about the Office 365 APIs, post to Stack Overflow. Make sure that your questions or comments are tagged with [MicrosoftGraph].

Thanks, and happy coding!
Your Microsoft Graph samples development team

See on GitHub Suggest on UserVoice Share on Twitter

D, [2016-08-11T18:05:56.364567 #57550] DEBUG -- : Code: 400 D, [2016-08-11T18:05:56.364678 #57550] DEBUG -- : Message: Bad Request I, [2016-08-11T18:05:56.368518 #57550] INFO -- : Rendered pages/callback.html.erb within layouts/application (0.3ms) I, [2016-08-11T18:05:56.370380 #57550] INFO -- : Completed 200 OK in 1988ms (Views: 5.4ms | ActiveRecord: 0.0ms) ::1 - - [11/Aug/2016:18:05:56 +0530] "POST /send_mail HTTP/1.1" 200 - 1.9915

The ruby version is 2.3.0 and am running it in Mac Capitan version 10.11

Let me know if you need any more info.

Regards,

leenasn avatar Aug 11 '16 13:08 leenasn

@leenasn

I tried with ruby 2.3.0 on Mac and unfortunately it works for me.

We are going to need more information. Could you add the following line to app > controllers > pages_controller.rb to line146?

 logger.debug response.body

You should see more information in the log, something like:

{
  "error": {
    "code": "ErrorInvalidRecipients",
    "message": "At least one recipient isn't valid., Recipient \"bad\" isn't resolved. All recipients must be resolved before a message can be submitted.",
    "innerError": {
      "request-id": "0a4d510f-c111-46dc-a7e5-51cedf2e1409",
      "date": "2016-08-11T21:26:55"
    }
  }
}

ricalo avatar Aug 11 '16 21:08 ricalo

@leenasn Thanks for reporting the issue! Please reopen this if you're still having problems.

DianeD avatar Jan 18 '17 19:01 DianeD