Skip to content Skip to sidebar Skip to footer

How To Send Put Request With Retrofit String And Array List Of Model I Need To Use Url Encoded

can anyone guide me how to send PUT request with this json { 'delivery_status': 'Partially Completed', 'signatures': '==skdjfkjdsakjhfoiuewyrdskjhfjdsaf', 'assignee_note': '

Solution 1:

There can be many ways to implement this call via Retrofit, the most easy I can think is to make model classes.

Your call will look like-

@PUT(""delivery_notes/update/1.json"")
Call<ApiResponse<UploadDeliveryNote>> postDeliveryNote(@Body Example example);

and call it like

Exampleexample=newExample();
    example.setAssigneeNote();
    example.setDeliveryStatus();
    example.setReturnedProducts();
    apiInterface.postDeliveryNote(example);

Example.java

publicclassExample {

    @SerializedName("delivery_status")
    @ExposeprivateString deliveryStatus;
    @SerializedName("signatures")
    @ExposeprivateString signatures;
    @SerializedName("assignee_note")
    @ExposeprivateString assigneeNote;
    @SerializedName("id")
    @ExposeprivateString id;
    @SerializedName("returned_products")
    @ExposeprivateList<ReturnedProduct> returnedProducts = null;

    publicStringgetDeliveryStatus() {
        return deliveryStatus;
    }

    publicvoidsetDeliveryStatus(String deliveryStatus) {
        this.deliveryStatus = deliveryStatus;
    }

    publicStringgetSignatures() {
        return signatures;
    }

    publicvoidsetSignatures(String signatures) {
        this.signatures = signatures;
    }

    publicStringgetAssigneeNote() {
        return assigneeNote;
    }

    publicvoidsetAssigneeNote(String assigneeNote) {
        this.assigneeNote = assigneeNote;
    }

    publicStringgetId() {
        return id;
    }

    publicvoidsetId(String id) {
        this.id = id;
    }

    publicList<ReturnedProduct> getReturnedProducts() {
        return returnedProducts;
    }

    publicvoidsetReturnedProducts(List<ReturnedProduct> returnedProducts) {
        this.returnedProducts = returnedProducts;
    }

}

ReturnedProduct.java

publicclassReturnedProduct {

    @SerializedName("id")
    @ExposeprivateString id;
    @SerializedName("quantity")
    @Exposeprivate int quantity;
    @SerializedName("reasons")
    @ExposeprivateString reasons;

    publicStringgetId() {
        return id;
    }

    publicvoidsetId(String id) {
        this.id = id;
    }

    public int getQuantity() {
        return quantity;
    }

    publicvoidsetQuantity(int quantity) {
        this.quantity = quantity;
    }

    publicStringgetReasons() {
        return reasons;
    }

    publicvoidsetReasons(String reasons) {
        this.reasons = reasons;
    }

}

Post a Comment for "How To Send Put Request With Retrofit String And Array List Of Model I Need To Use Url Encoded"