cancel
Showing results for 
Search instead for 
Did you mean: 

Swagger : Providing Payload to POST Request at runtime

Highlighted
New Contributor

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 2
Occasional Contributor

Re: Swagger : Providing Payload to POST Request at runtime

Hi,

 

Can you please explain little more your problem?

New Contributor

Re: Swagger : Providing Payload to POST Request at runtime

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

New Here?
Join us and watch the welcome video:
Final Interview in the Series
API_testing_mistake#7