cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

API capture POST/PUT content

JensDeveloper
Contributor II

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 GET requests working but now Iโ€™m trying to find a way to capture the content of the PUT/POSt method.

I have searched for pipeline parameters but only found QUERY_STRING and it doesnโ€™t capture the content.

Anyone knows a solution to this?

Regards

Jens

1 ACCEPTED SOLUTION

Supratim
Contributor III

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-
image

Response from postman
image

  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.

image

View solution in original post

2 REPLIES 2

Supratim
Contributor III

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-
image

Response from postman
image

  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.

image

Thanks a lot, this will help me immense. Now I understand it.

Regards Jens