简体   繁体   中英

How to test POST web service call that send data in Custom Object?

I am using Retrofit for REST API calls. I want to check some APIs in Postman but some Web service APIs send input data in Custom Object form.Unable to find how to test it in Postman or online .

Example :

@POST("/InsertBusinessInfo")
Call<Boolean> postBusinessInfo(@Body BusinessInfo businessRequest);

This BusinessInfo pojo class with some params with get/set methods

public class BusinessInfo {

    public String getFirstName() {
        return FirstName;
    }

    public void setFirstName(String firstName) {
        FirstName = firstName;
    }

    public String getLastName() {
        return LastName;
    }

    public void setLastName(String lastName) {
        LastName = lastName;
    }
}

How to test this in Postman . Is it the same as 1 by 1 params inserted in Body? Can anyone explain it?

Yes it should be simple:

In postman add the POST endpoint (eg myBaseUrl/InsertBusinessInfo/)

Then with POST selected, in the Body select form encoding (eg x-www-form-urlencoded).

Now add your POJO field name as 'key' and your field value as 'value'.

This should then POST to your endpoint.

In Postman open a request and from tabs below URL Select Body

from the options below select raw

Now mostly the object is serialized in to JSON, so get a JSON for your object

{"FirstName":"name...", "LastName":"name2..." ...}

(filled with data) and paste it in the large text area below and click send

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM