Home > Software engineering >  How to access Microsoft Graph Api using Jenkins for automation
How to access Microsoft Graph Api using Jenkins for automation

Time:07-16

I have recently migrated my test automation project from using smtp protocols to Microsoft Graph Api to automate sending emails and reading the replies. We are getting the access token using ClientSecretCredentialBuilder and we are able to send the emails and read the replies when run locally, however when the same tests are run through jenkins we are facing 404 : Not Found error when trying to send emails.

The Azure app is having all the required permissions to send and read the emails, am I missing anything in the permissions or do I have to install any Jenkins plugin to read the data from Microsoft Graph API services?

Below is the error that I am facing:

com.microsoft.graph.http.GraphServiceException: Error code: ResourceNotFound Error message: Resource could not be discovered.

POST https://graph.microsoft.com/v1.0/users/1/microsoft.graph.sendMail SdkVersion : graph-java/v3.2.0 [...]

404 : Not Found [...]

Thanks in advance for your help

CodePudding user response:

Since the code is working locally, I guess the problem lies on the Id of the user you are using.

Is https://graph.microsoft.com/v1.0/users/1/microsoft.graph.sendMail copy and pasted or did you changed the Id before posting it here for security reasons? If you didn't change the url, this should be the issue because you will not have a user with Id: 1. Most of the time, the Id will be a GUID, read more here.

Another possibility would be that you are saving the Id of the user you need for testing in an environment variable and you forgot to add this variable in Jenkins.

  • Related