首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >MailGun Api示例

MailGun Api示例
EN

Stack Overflow用户
提问于 2017-11-30 03:13:14
回答 0查看 831关注 0票数 0

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

我已经输入了my :域名和API密钥。

代码语言:javascript
复制
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.JsonNode;
import com.mashape.unirest.http.Unirest;
import com.mashape.unirest.http.exceptions.UnirestException;

public static JsonNode sendSimpleMessage() throws UnirestException {

    HttpResponse<JsonNode> request = Unirest
            .post("https://api.mailgun.net/v3/" + "sandbox21801cd223b94bbc92dbd011424xxxxx.mailgun.org"
                    + "/messages")
            .basicAuth("api", "xxx8013e6a2e75889370b0d2e670b2e")
            .queryString("from", "Excited User <notifications-noreply@miempresa.com>")
            .queryString("to", "joseluis.garcia@miempresa.com").queryString("subject", "hello")
            .queryString("text", "testing").asJson();

    return request.getBody();
}

错误:

代码语言:javascript
复制
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
EN

回答

页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/47560105

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档