Create a json from 2 local varibles for post Api

I have 2 local variables password and username on my login screen.I need these 2 variables to pass as a json of format {"username":username,"password":password}

In my rest api as a request body  in post methood.

How can i achieve this.

Do I need to store as a local storage entity and json serialize and pass or any other methood

Hi Jibin,

You can create a structure having attribute username and password then use json serialize method before passing it to the API.


Manish Jawla

Hi Jibin,

For passing these details to the API as Manish said you need a structure. It will be created automatically when you add API methos to consume and set request sample json. Please follow below steps explained in the documents and you will be able to understand how it works: