Code example for HttpPut

Methods: setEntity, setHeader

0
 
        if (Utils.isEmpty(putBody)) {
            throw new IllegalArgumentException("Put body must not be null or empty to run PUT request.");
        } 
 
        HttpPut httpPut = new HttpPut(url);
        //TODO: make this support non-JSON types. 
        httpPut.setHeader("Content-type", "application/json");
        ByteArrayEntity putEntity;
        try { 
            putEntity = new ByteArrayEntity(putBody.getBytes("UTF-8"));
        } catch (UnsupportedEncodingException e) {
            throw new HttpUtilsException("Unsupported encoding for PUT body.", e);
        } 
        httpPut.setEntity(putEntity);
        return httpPut;
    } 
 
     
    /* (non-Javadoc) 
     * @see com.hubspot.android.utils.http.IHttpUtils#getReaderForPost(java.lang.String, java.lang.String)