简体   繁体   中英

How to automatically make POST REST API requests in c#

I have a project scenario that requires me to make POST REST API requests to url endpoints automatically, so basically I have a view/table in my SQL database and I want to iterate through that view/table to find what changed for a specific column(email) and make a POST request to update only what was changed from view/table columns in SQL and update the JSON in the url endpoint for column(email) This needs to be done automatically either daily, weekly, or monthly.

Here is a snippet of JSON structure and the column that I want to overwrite is (emailAddress)

 { "additionalAddressInformation": "", "addressLine": "ADF Test Street", "addressLine1": "", "alternatePhone": "", "city": "TEST", "companyLocationID": null, "countryID": 00, "emailAddress": "adftestingautotask@test.com", "emailAddress2": null, "emailAddress3": null, "extension": "", "externalID": "", "facebookUrl": "", "faxNumber": "", "firstName": "Azure Data Factory", "isActive": 0, "isOptedOutFromBulkEmail": false, "lastName": "Azure", "linkedInUrl": "", "middleInitial": "B", "mobilePhone": "", "namePrefix": null, "nameSuffix": null, "note": "", "receivesEmailNotifications": true, "phone": "(000) 000-000", "primaryContact": false, "roomNumber": "", "state": "NY", "title": "ADF Developer", "twitterUrl": "", "zipCode": "0000", }

What I have done so far:

  1. I have made some researches and came across a library called HangFire, not sure if is the correct way to approach my project scenario.
  2. I have created a pipeline in Azure Data Factory and was able to POST manually, but I am not sure if I can use Web activity to create the POST call to include column (email) in the POST call as a parameter or variable. Any recommendation or suggestions would help. Thanks in advance

Yes, HangFire is one of the methods - if you prefer creating an app that takes care of it's own and just runs on server - it's more then enough.

Alternative approach would be to use tools like Jenkins to schedule a repeating task on the server side.

It all depends in this case on preference and available resources - more complicated but self-sufficient app vs simpler app that just scan the db and use post fired up by third party solution.

And please, do mind that my answer is opinion-based - I don't think that there is a one proper way of handling this situation without going into much detail.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM