0

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?

chenrui
  • 8,910
  • 3
  • 33
  • 43
Harsh Bhavsar
  • 1,561
  • 4
  • 21
  • 39

2 Answers2

0

Yes it should be simple:

In postman add the POST endpoint (e.g. myBaseUrl/InsertBusinessInfo/)

Then with POST selected, in the Body select form encoding (e.g. 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.

GordonW
  • 1,120
  • 2
  • 16
  • 36
  • Still not working! End point after InsertBusinessInfo ? Explain your last line. – Harsh Bhavsar Jul 12 '17 at 11:59
  • What error code do you get? a 404, 500, etc? The above works fine for me, if your getting 404 then your endpoint/url incorrect, if you get a 500 then theres something wrong server side. Postman will give you this in response. – GordonW Jul 12 '17 at 12:35
  • The server encountered an error processing the request. The exception message is 'The incoming message has an unexpected message format 'Raw'. The expected message formats for the operation are 'Xml', 'Json'. This can be because a WebContentTypeMapper has not been configured on the binding. See the documentation of WebContentTypeMapper for more details.'. See server logs for more details. The exception stack trace is: Request Error – Harsh Bhavsar Jul 13 '17 at 09:08
0

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

Yazan
  • 6,074
  • 1
  • 19
  • 33