locked
How do I handle an HTTP GET Request sent from an outside resource. RRS feed

  • Question

  • User1391845369 posted

    I am pretty new working with API's and handling these type of request.  So please be patient with me.

    I have a client that is sending me a GET request via URL with the parameters set in the URL query.

    Example URL: https://mywebsite.com/OptIn.aspx?Email=steven.thomas@email.com&verification=1234&Name=Steven%20Thomas&pin=2222

    1) Optin.aspx is a page I created, the client is formatting the URL and sending it to that location.

    2) I need to capture the request every time it is processed and parse out the data to make a database insert.  How do I pick up the request every time is sent? 

    3) Will it run with just a standard  .Net C# asp page or do I have to create a service....?

    Monday, March 30, 2020 2:26 PM

Answers

  • User1391845369 posted

    mgebhard,

    This is all I know at this point.

    1) The client is using Cognito Forms. 

    2) User fills out that form and they told me they were sending a HTTP GET Response to this location in this format: https://mywebsite.com/OptIn.aspx?Email={email}&verification={Last 4 of SSN}&Name={First and Last Name}&pin={PIN Number}

    3) I have a Optin.aspx page in place and using Page_Load and parsing out the query string.  Just started coding so I have not had a chance to test anything yet.

    Will this method work?   

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, April 2, 2020 3:39 PM

All replies

  • User475983607 posted

    2) I need to capture the request every time it is processed and parse out the data to make a database insert.  How do I pick up the request every time is sent? 

    The Page_Load event will run every time the page is requested.  You can get the URL parameters from the Request object.

    string email = Request.QueryString["Email"];

    https://docs.microsoft.com/en-us/previous-versions/iis/6.0-sdk/ms524784(v%3Dvs.90)

    Monday, March 30, 2020 11:45 PM
  • User1391845369 posted

    mgebhard,

    I am familiar with using the Page_Load event and the query string.  I am using this in other pages in my application but the user actually is interacting.  

    So from what you are saying is that if a HTTP GET request is being to sent to my page via a service/other source.   The web server will pick that request up and process that page automatically without human intervention (assuming I have Page_Load code in place) ?  I don't need to create a web-service or anything?

    Thursday, April 2, 2020 2:23 PM
  • User475983607 posted

    steven0608

    The web server will pick that request up and process that page automatically without human intervention (assuming I have Page_Load code in place) ?

    Correct.

    steven0608

    I don't need to create a web-service or anything?

    Your original question uses an aspx example which shaped my response.  A web service will work too.   Any code that runs in response to an HTTP GET (or POST) is all you need. 

    The design approach depends on how the application is intended to work.  What transport have you and the client decided on?  REST?  SOAP?  What about data format?   HTML Forms, JSON, XML, SOAP? 

    Thursday, April 2, 2020 2:37 PM
  • User1391845369 posted

    mgebhard,

    This is all I know at this point.

    1) The client is using Cognito Forms. 

    2) User fills out that form and they told me they were sending a HTTP GET Response to this location in this format: https://mywebsite.com/OptIn.aspx?Email={email}&verification={Last 4 of SSN}&Name={First and Last Name}&pin={PIN Number}

    3) I have a Optin.aspx page in place and using Page_Load and parsing out the query string.  Just started coding so I have not had a chance to test anything yet.

    Will this method work?   

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, April 2, 2020 3:39 PM