Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
K11
Contributor
Contributor

Post method in the tREST

Hi Guys,
I am trying to print the HTTP body in the tLogRow sending it through the tREST.How can I Print the REquest Body?

Labels (2)
6 Replies
Shicong_Hong
Support
Support

Hello @K11 

Do you want to print the body string of http body?

2024-04-01_11-33-49.png

If so, assign the body string to a context variable and set the http body field using context variable, then you can print the value of context variable on any other components such as tJava, tJavaRow or log the value of context variable to console through tFixedFlowInput--main--tLogRow.

Regards

Shicong

K11
Contributor
Contributor
Author

HI @Shicong_Hong ,

Thank you very much,if it is possible can you share one example. It will be a great help.
Below is the HTTP body I was passing
"{
\"disbursement_date\":\"11-02-2024\",
\"disbursement_mode\":\"ECS\",
\"branch_code\":\"0001\",
\"center_code\":\"332\",
\"officer_code\":\"V45801\",
\"disbursements[0][account_no]\":\"12345667\",
\"disbursements[0][amount]\":\"12345\",
\"disbursements[0][bank_account_no]\":\"11222222222\",
\"disbursements[0][bank_wire_code]\":\"ABC1234567\",
\"disbursements[0][remark]\":\"\",
\"disbursements[0][foreclosure_reason]\":\"\"
}"

Regards
K11

Shicong_Hong
Support
Support

If you want to print this http body on the console, you just need to do it on a tJava component before tRest, for example:

tJava--onsubjobok--tRest

on tJava:

context.body="your http body string";

System.out.println(context.body);

On tRest comonent, set the Http body field using context variable: context.body

Regards

Shicong

K11
Contributor
Contributor
Author

Hi Shicong_Hong,


How can i show the above payload in the table format keys as column  and value in rows ? and how to send form-data in the tRest

 

Shicong_Hong
Support
Support

If you print the payload string using tLogRow component, you can select the 'Table' mode. 

2024-04-02_18-25-28.png

K11
Contributor
Contributor
Author

Is this payload correct for the body. I am getting below error

K11_0-1712056337981.png

K11_1-1712056452337.png