MailGun Api示例

时间:2017-11-29 19:13:14

标签: mailgun

我正在使用mailgun进行测试,我复制了示例并输入了我的域名和密码,但它没有,我也没有收到邮件

我已经把我的:域名和API密钥。

Exception in thread "main" com.mashape.unirest.http.exceptions.UnirestException: java.lang.RuntimeException: java.lang.RuntimeException: org.json.JSONException: A JSONArray text must start with '[' at character 1
at com.mashape.unirest.http.HttpClientHelper.request(HttpClientHelper.java:143)
at com.mashape.unirest.request.BaseRequest.asJson(BaseRequest.java:68)
at com.abalia.crm482.sms_mail.mailSendInfobip.sendSimpleMessage(mailSendInfobip.java:22)
at com.abalia.crm482.sms_mail.mailSendInfobip.main(mailSendInfobip.java:11)
Caused by: java.lang.RuntimeException: java.lang.RuntimeException: org.json.JSONException: A JSONArray text must start with '[' at character 1
at com.mashape.unirest.http.HttpResponse.<init>(HttpResponse.java:106)
at com.mashape.unirest.http.HttpClientHelper.request(HttpClientHelper.java:139)
... 3 more

Caused by: java.lang.RuntimeException: org.json.JSONException: A JSONArray text must start with '[' at character 1
at com.mashape.unirest.http.JsonNode.<init>(JsonNode.java:51)
at com.mashape.unirest.http.HttpResponse.<init>(HttpResponse.java:95)
... 4 more
Caused by: org.json.JSONException: A JSONArray text must start with '[' at character 1
at org.json.JSONTokener.syntaxError(JSONTokener.java:410)
at org.json.JSONArray.<init>(JSONArray.java:113)
at org.json.JSONArray.<init>(JSONArray.java:157)
at com.mashape.unirest.http.JsonNode.<init>(JsonNode.java:48)
... 5 more

错误:

read_excel

1 个答案:

答案 0 :(得分:0)

当我传入错误的密钥时,我遇到了同样的问题。通过使用私钥(您可以从mailgun控制台找到)替换公钥,我解决了这个问题。

基本上,传入错误密钥时发生的事情是这样的: 如果在内部调试com.mashape.unirest.http.HttpResponse<T>,在构造函数中,您将找到如何构建JsonNode。如果您未通过密钥身份验证,那么假设为json字符串的rawBody将成为一个简单的字符串:Forbidden。尝试从这样的字符串构建一个JsonArray会抛出这样的异常。

希望有所帮助〜