vprashanth23 0 Report post Posted July 15, 2019 Hi Team, I have a scenario where i need to test a Post method of REST API.I have all the data required for the request's json body in a file.How to set this file as body for request? Im trying to do somethng like below but im getting code 400 bad request.I tried using multipart data but it is sending content type as body so getting in valid JSON. Any help is appreciated.Thanks in advance. Quote Share this post Link to post Share on other sites
sergei 0 Report post Posted July 15, 2019 Hi, You have to use the JavaScript operator to read a content from the file. Add to the operator something like the following: var fso,filehandle,contents; fso = new ActiveXObject("Scripting.FileSystemObject"); filehandle = fso.OpenTextFile("D:\\Temp\\WAPT\\5.0 Test\\JSONFromFile\\json.txt",1); contents = filehandle.ReadAll(); log.message(contents); context.variable("test") = contents; filehandle.close(); Then use the variable "test" in a POST request body. Quote Share this post Link to post Share on other sites
vprashanth23 0 Report post Posted July 17, 2019 It is working. Thanks Sergei ! Quote Share this post Link to post Share on other sites