Forum Discussion

chikki1982's avatar
chikki1982
New Contributor
6 years ago

Swagger : Providing Payload to POST Request at runtime

Hi Team,

 

I have a swagger as defined in the attached Sample.yaml

As you can see the POST method takes a definition as the body and when I see this in the swagger editor (https://editor.swagger.io/), (attached  isthe screen shot SwaggerUI.png), at runtime I need to provide the contents of the definition as the body when the content-type is applicaiton/json. I want to understand what is the correct way of providing the body for this post operation

 

Option 1 :

{

       "id":"123",

       "name":"swagger",

       "address":"NY"

}

 

Option 2 : 

 

{

     "input" : {

                         "id" : "123",

                         "name" : "Swagger".

                         "address" : "NY"

                 }

}

 

Or as providers we can support both the options? Any answer in this regard would be much appreciated.

Let me know if you would need any more information.

 

Thanks,

Sree

 

 

 

2 Replies

  • Shivani1's avatar
    Shivani1
    Occasional Contributor

    Hi,

     

    Can you please explain little more your problem?

    • chikki1982's avatar
      chikki1982
      New Contributor

      Hey Shivani,

       

      Thanks for the response. The situation here is as such not a problem for me, but I am trying to understand what is the correct way of providing body for a POST request. When the POST request has a body parameter as defined by a definition, then at runtime do we have just pass the properties of the definition as body (as shown in option1)? Or do we have to include the root element in the body (as shown in option2)? This is applicable only for content type application/json. Thanks

       

      Regards,
      Sree