Cannot use the .api call on v3
amgra2020 opened this issue · comments
amgra2020 commented
Issue Summary
I am not able to use the .api call on v3. I apologize as this is probably a simple question, but I am fairly new to programming. I've got all the libraries I know to have and have tried to follow the examples on this main page.
Steps to Reproduce
Code Snippet
SendGrid sg = null;
if(fmi.getAgencyName().equals("DD"))
{
sg=new SendGrid("apikey","KEY1");
}
else if(fmi.getAgencyName().equals("DAG"))
{
sg=new SendGrid("apikey","KEY2");
}
else
{
sg=new SendGrid("apikey","KEY3");
}
Request request = new Request();
try {
//request.method = Method.POST;
request.setMethod(Method.POST);
//request.endpoint = "mail/send";
request.setEndpoint("mail/send");
//request.body = mail.build();
request.setBody(mail.build());
Response response = sg**.api**(request); <--------------This is causing the error. It doesn't give me an option for .api
int result = response.getStatusCode();
System.out.println(response.getStatusCode());
System.out.println(response.getBody());
System.out.println(response.getHeaders());
if(result == 202)
{
Alert alert = new Alert(Alert.AlertType.INFORMATION);
alert.setTitle("Victory Dialog");
alert.setHeaderText("We sent the emails");
alert.setContentText("The sending of the emails has been successful! Rejoice!");
alert.show();
}
else
{
Alert alert = new Alert(Alert.AlertType.ERROR);
alert.setTitle("Panic Dialog");
alert.setHeaderText("Something went wrong");
alert.setContentText(response.toString());
alert.show();
results = results.concat("Additional error information: \n"+response.toString());
System.out.println(results);
}
}
catch (IOException ex)
{
System.out.println( ex.toString());
results = results.concat("Additional error information: \n"+ex.toString());
System.out.println(results);
}
Exception/Log
I'm not able to compile or run to get a log
Technical details:
- sendgrid-java version: 4.7.1
- java version: 1.8.0_112
Elmer Thomas commented
Hello @amgra2020,
Thanks for taking the time to submit this issue!
Have you tried getting the "hello email" example to work? It looks like you may be using an old example.
With best regards,
Elmer
Shwetha Radhakrishna commented
@amgra2020 Please feel free to reopen if you need further assistance