Page 1 of 1

post json to rest web service

Posted: Fri Sep 23, 2016 7:15 pm
by rickc
I would like to create a project that will:
  • Read a record from a database (select statement)
  • Assemble a json string in a variable
  • Post the json to a rest web service
  • Loop and read the next record from the db
I was able to setup a project to post json from a static file(post raw data). I'd like to generate the JSON from the SQL statement and post to the web services one record at a time.

What is the best way to accomplish this?


RickC

Re: post json to rest web service

Posted: Mon Sep 26, 2016 10:16 am
by Support_Rick
It should be something similar to ...
Code: Select all
<project name="DB Loop"
         mainModule="Main"
         version="2.0"
         logLevel="verbose">

	<module name="Main">

		<sql resourceId="MyDBServer"
		     version="1.0">
			<query outputVariable="Data">
				<statement>Select F1, F2, F3 from DB.Table</statement>
			</query>
		</sql>

		<forEachLoop label="Loop through Data"
		             itemsVariable="${Data}"
		             currentItemVariable="Row">

			<setVariable label="setVar:  JSON String"
			             name="JSON"
			             value="&apos;Set JSON String here&apos;"
			             version="2.0" />


			<https label="Post Raw Data"
			       resourceId="HTTPS Server"
			       version="1.0" />

		</forEachLoop>
	</module>

</project>