1

推奨される v3 ライブラリで使用される Mailjet の REST API に関して深刻な問題があります。

更新しようとすると、初めてエラーなしで更新できますが、もう一度更新しようとすると、NullPointerException. それにもかかわらず、Mailjet Server 部分の統計を更新します。

また、私が得るHTTPレスポンスはHTTP/1.1 500 Internal Server Error

使用したコード:

thisUser=cl.createCall(User.Update).identifiedBy(UserProperty.ID, **myUniqueID**).property(UserProperty.USERNAME, propertyValue).execute();

どんな考えでも大歓迎です。

コメントの後、ここに関数があります:

         @Path("/userUpdate/{propertyName}/{propertyValue}")
     @GET
     public Response userUpdate(@PathParam("propertyName") String propertyName, @PathParam("propertyValue") String propertyValue) throws ClientProtocolException, IOException{
         MailJetApiClient cl=null;
         User thisUser=null;
         Response resp=null;

         StringEntity stringEntity = null;

        try {
            cl = MailjetUsersRest.createClient();
        } catch (MailJetClientConfigurationException e2) {
            // TODO Auto-generated catch block
            e2.printStackTrace();
        }

        try {
            thisUser=cl.createCall(User.Get).identifiedBy(UserProperty.ID, ___MY_UNIQUE_ID___).execute();
        } catch (MailJetApiCallException e2) {
            // TODO Auto-generated catch block
            e2.printStackTrace();
        }
        String email = thisUser.getEmail();
        String lastip = thisUser.getLastIp();
        Date lastlogin = thisUser.getLastLoginAt();
        String local = thisUser.getLocale();
        String timezone = thisUser.getTimezone();
        Date warned = thisUser.getWarnedRatelimitAt();          

         try {

            cl = MailjetUsersRest.createClient();

            switch(propertyName){

            case "Username":

                thisUser=cl.createCall(User.Update).identifiedBy(UserProperty.ID, ___MY_UNIQUE_ID___).property(UserProperty.USERNAME, propertyValue).execute();

                resp = Response.status(200).entity(thisUser).build();

                break;

            default:
                System.out.println("Invalid propertyName.");
                break;
            }

        } catch (MailJetClientConfigurationException | MailJetApiCallException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }


            return resp;
     }
4

1 に答える 1

1

はじめに、Mailjet をご利用いただきありがとうございます。

いくつかのテストの後、問題を再現できませんでした。私が使用したコードの下にあります。

ただし、こちらのサポートでチケットを開くことを強くお勧めします。

作業コード

各呼び出しの前にクライアントを再構築することは不要であり、悪い習慣と見なされることに注意してください。

// Build a Mailjet client config
MailJetClientConfiguration config;

config = new MailJetClientConfiguration()
                .setBaseUrl("https://api.mailjet.com/v3/REST/")
                .setDefaultApiKey(System.getenv("MJ_PROD_PUBLIC"))
                .setDefaultSecretKey(System.getenv("MJ_PROD_PRIVATE"));

// Build a Mailjet client
MailJetApiClient client = config.buildClient();

// Your code (adapted to my environment, ie no 'Response' object 
// and no client factory.)
User thisUser = null;

try
{
    // Note that the 'L' in the 'identifiedBy' value fi is necessary
    thisUser = client
                .createCall(User.Get)
                .identifiedBy(UserProperty.ID, /*Our user's ID*/L)
                .execute();
}
catch (MailJetApiCallException e2)
{
    e2.printStackTrace();
}

String email = thisUser.getEmail();
String lastip = thisUser.getLastIp();
Date lastlogin = thisUser.getLastLoginAt();
String local = thisUser.getLocale();
String timezone = thisUser.getTimezone();
Date warned = thisUser.getWarnedRatelimitAt();

try
{
    thisUser = client
                .createCall(User.Update)
                .identifiedBy(UserProperty.ID, /*Our user's ID*/L)
                .property(UserProperty.USERNAME, "DevRel Team Mailjet")
                .execute();

}
catch (MailJetApiCallException e)
{
    e.printStackTrace();
}

NullPointerException最後のビット (更新プロセス) をコピーして貼り付け、更新呼び出しが 2 回 (もちろん、同じ新しいユーザー名なしで) 実行されるようにしても、エラーは発生せず、 HTTP エラー コードや 500も発生しません。
それに応じてユーザー名が変更されます。

そうですね、上記のとおり、こちらからサポートにお問い合わせください。これにより、より適切なサポートが可能になります。

この回答に満足している場合は、同様の問題を経験している他の人がこれが役に立ったことを知ることができるように、それを受け入れて賛成することを忘れないでください:-)

于 2015-07-03T09:15:51.490 に答える