0

I need to pass parameter to do POST on a endpoint

For key:value pair I do as below

param("key", "value")

How to achieve for below parameter object

"context": { "description": "some_value" }

Thanks in advance.

vikramvi
  • 3,312
  • 10
  • 45
  • 68

1 Answers1

2

There are 4 types of HTTP post method which is specified by "Content-Type" Header.Normally content-type value is "application/x-www-form-urlencoded" and the content of request body is just like

name=nameValue&age=10

However the format you need is just like JSON.So maybe the JSON-type POST can meet your need.Just set Content-type Header to "application/json" and the content of request body is like

{"name":"name","age":10}

and the way used in rest-assured can refer to this question setting content type in rest assured

reference application/x-www-form-urlencoded or multipart/form-data?

Community
  • 1
  • 1
CALTyang
  • 1,128
  • 1
  • 8
  • 13