Dear Team,
Can you share the sample or demo code where i can fetch the bulk data from sql server in mule soft and that bulk data i want to push in third party api which is accepting data as json
Dear Team,
Can you share the sample or demo code where i can fetch the bulk data from sql server in mule soft and that bulk data i want to push in third party api which is accepting data as json
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Gaurav SrivastavaPosted Jun 6, 2023, 6:02 PM
Dear Rajkiran,
I hope you are doing well.
thanks for your reply, but i am using latest version of mule and it is not supporting object to json for that i am using dataweave and for that i dont have any issue or concern, what i am looking for industry standard best practice sample code like it will execute daily once in a day the job or schedular for fetching t-1 day records from sql database as bulk in json and then it should post to third party api. But what i am looking for industry best practices for the same lets say including caching, or if any error happend so retry to post again untill the bulk loaded data not successfully pushed to third party api. I hope you understand my query.
so appreciate if you have such use case sample code so kindly suggest or post.
Rajkiran SwainPosted Jun 5, 2023, 4:01 PM
n the above code:
The
db:selectcomponent is used to fetch the desired bulk data from the SQL Server database. Make sure you have a properly configured database connector (SQLServer_Config) with the required connection details.The
json:object-to-json-transformeris used to convert the fetched data to JSON format.The
http:requestcomponent is used to make an HTTP POST request to the third-party API. Ensure that you have a properly configured HTTP connector (ThirdPartyAPI_Config) with the necessary endpoint details.The fetched data, converted to JSON, is passed as the payload of the HTTP POST request.
Please note that you'll need to configure the database connection and the HTTP connector with the appropriate details according to your environment and the third-party API specifications.
Feel free to customize the code as per your specific requirements and data structures.
If you have any further questions or need additional assistance, please let us know.
Gaurav SrivastavaPosted Jun 5, 2023, 2:43 PM
Dear Mohammad,
thank you so much for quick response, but it would be helpful if you have any sample code for the same.
yes i am able to fetch bulk data from sql server database and display as json but if i want to insert bulk data in third party API as best practice so can you suggest any sample code for the same and another use case is, i want this push as scheduled job i mean i want to push lets say this bulk data on daily basis to third party once in a day automatically.
appreciate if you can suggest example with source code.
Mohamed Azarudeen ZPosted Jun 5, 2023, 11:53 AM
Hi gaurav
hope you have comected database nad http connectors find tyhe sample code below