Home » Java » android – how to convert text/string into application/octet-stream format using java-Exceptionshub

android – how to convert text/string into application/octet-stream format using java-Exceptionshub

Posted by: admin February 25, 2020 Leave a comment

Questions:

How to convert string into application/octet-string . I want to send an email using api call

public void SendEmail(){
    String email = user.getEmail();
    OkHttpClient client = new OkHttpClient();

    String subject = "Order Placed Successfully";
    String content = "Your order #"+OrderId+"is placed successfully";


    String finalcontent = "{\"sender\":{\"name\":\"Shoppy\",\"email\":\"[email protected]\"},\"to\":[{\"email\":\"[email protected]\"}],\"textContent\":\"nnkdvsnkvsknknlsv\",\"subject\":\"k bkbbjkbkjbjb\",\"replyTo\":{\"email\":\"[email protected]\"}}";

    MediaType mediaType = MediaType.parse("application/octet-stream");
    RequestBody body = RequestBody.create(mediaType,finalcontent);
    Request request = new Request.Builder()
            .url("https://api.sendinblue.com/v3/smtp/email")
            .post(body)
            .addHeader("accept", "application/json")
            .addHeader("content-type", "application/json")
            .addHeader("api-key", "xkeysib")
            .build();

    try {
        Response response = client.newCall(request).execute();
    } catch (IOException e) {
        e.printStackTrace();
    }
}

In the above code … i want the email and message to be retrieved from an edittext in android

How to&Answers: