cancel
Showing results for 
Search instead for 
Did you mean: 

Pass JSON request body in a PUT Request

SOLVED
Highlighted
Frequent Contributor

Pass JSON request body in a PUT Request

Hello,

 

In one of my programs, I'm trying to send a put request and capture the response.

For PUT requests, I have a URI and JSON request body. 

 

I also have to parameterize 4 fields in the JSON request. I don't know if test complete would support such a solution.

I don't want to have JSON request body embedded in my code because of it's size, and also for the reusability of the code. 

 

Is there a way I can keep the JSON request body in an external file, reference that file in the program, pass reuqired paramenters as the args, and send the http reuqest using aqHttp Object ? 

 

Any thoughts would be helpful

 

Thank you

Al

 

2 ACCEPTED SOLUTIONS

Accepted Solutions
Highlighted
Community Hero

Re: Pass JSON request body in a PUT Request

Hi Al,

 

While it depends on the specifics of your case/program, in general you should be able to do what you need with the help of the aqHTTP.CreateRequest() method.

To read the content of JSON body from the file you may use the aqFile object provided by TestComplete.

See TestComplete documentation for more details and code examples.

 

Regards,
  /Alex [Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================

View solution in original post

Highlighted
Community Hero

Re: Pass JSON request body in a PUT Request

Hi Al,

 

Yes, you should be able to do this using the aqHttpRequest.SetHeader() method.

 

Regards,
  /Alex [Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================

View solution in original post

3 REPLIES 3
Highlighted
Community Hero

Re: Pass JSON request body in a PUT Request

Hi Al,

 

While it depends on the specifics of your case/program, in general you should be able to do what you need with the help of the aqHTTP.CreateRequest() method.

To read the content of JSON body from the file you may use the aqFile object provided by TestComplete.

See TestComplete documentation for more details and code examples.

 

Regards,
  /Alex [Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================

View solution in original post

Highlighted
Frequent Contributor

Re: Pass JSON request body in a PUT Request

Thanks Alex! I'm wondering whether an authentication token can be passed in the http request as well?

 

Thank you

Al  

Highlighted
Community Hero

Re: Pass JSON request body in a PUT Request

Hi Al,

 

Yes, you should be able to do this using the aqHttpRequest.SetHeader() method.

 

Regards,
  /Alex [Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================

View solution in original post

New Here?
Join us and watch the welcome video:
Announcements
Join TechCorner Challenge!
Want a fun and easy way to learn TestComplete? Try solving weekly TechCorner challenges and get into the Leaderboard!

Challenge Status

Changing options from outside of TestComplete

Participate!

How to execute remote test and obtain results via Test Runner REST API

Participate!

Comparing content of HTML table with Excel file data

Participate!

Compare HTML table with Excel file and correct data in the file

Participate!
Top Kudoed Authors