Skip to main content
The First Step
December 4, 2020
Question

Get A2P SMS - get delivery status from message ID in Java

Is there a way for me, in Java, to get the delivery status of an SMS by ID? I am using the 1.6.1 java client that was just released about a week ago. Looking at the doc (https://github.com/ringcentral/ringcentral-java/blob/master/samples.md ) I can’t tell because Send A2P SMS and Get A2P SMS both seem to refer “restRequestConfig” which has no explanation yet that I see. Perhaps it does not yet exist for Java? I would really like to subscript a get notification if that was possible in the Java interface?

    1 reply

    PhongVu
    Community Manager
    Community Manager
    December 4, 2020

    Please hold on to use the Java SDK with A2P methods directly as we are updating the specs which may cause code breaks later.

    For now, I recommended to use the post() and get() method directly with specified endpoint and params.

    public ResponseBody get(String endpoint, Object queryParameters) throws IOException, RestException {
        return request(HttpMethod.GET, endpoint, queryParameters, null);
    }
    public ResponseBody post(String endpoint, Object object) throws IOException, RestException {
        return request(HttpMethod.POST, endpoint, null, object, ContentType.JSON);
    }

    E.g.

    public class Filters {
            public String view = "";
            public String dateFrom = "";
            public String dateTo = "";
    }
    /*
    Other valid filters
        perPage: integer
        batchId: string
        direction: Array
        phoneNumber: Array
    */
    
    public void read_a2p_message_store() {
        var params = new Filters();
        params.view = "Detailed";
        params.dateFrom = "2020-11-20T00:00:00.000Z";
        params.dateTo = "2020-11-30T00:00:00.000Z";
    
        ResponseBody resp = restClient.get("/restapi/v1.0/account/~/a2p-sms/messages", params);
        System.out.println(resp.string());
    }

    We will update the SDK as soon as we can.