Forum Discussion

JensDeveloper's avatar
JensDeveloper
Contributor II
4 years ago
Solved

API capture POST/PUT content

Hi, I was wondering how to capture the content of a PUT/POST call to update/insert the data into a database. I know how to capture the URL through pipeline paramters (PATH_INFO) to make all my GE...
  • Supratim's avatar
    4 years ago

    Hi @JensDeveloper,
    It can be achieved in two ways-

    1. You can use a unlinked (no input/open input) mapper as you first snap. (Hope you are sending json data only. )
      Then whatever payload you are sending from client it can be accessible in mapper. Let say you are sending a payload like- [{“name”:“Supratim”,“lname”:“Das”},{“name”:“Supratim2”,“lname”:“Das”}] , you will get response like [{“name”:“Supratim”},{“name”:“Supratim2”}]. Please refer below two pics.
      One more important thing when you use open mapper then you need to pass Content-Type as “application/json” from HTTP header.

    In Pipeline-

    Response from postman

    1. Rather having open mapper view, you can use JSON parser (If you are sending JSON, Incase of XML you have to start with unlinked XML parser.) then rest of the part remain same. In this you can ignore to pass Content-Type from header. This option we can choose where we are using json schema to validate any complex json payload before processing.

    For both the case, if you want to capture entire payload, you can use “$” instead of $name.