I am new at web development, so how to make http request\respone for some site (http://google.com)
Thank you!
P.S.
I mean, that when my SomeController activated- i want send http request to another site,get data from it and send it into View
A client (browser) submits HTTP request to the server; then the server returns a response to the client. The response contains status information about the request and also contains the requested content. GET - requests data from a specified resource, http://google.com - you type this url in browser and hit the enter key, it's a get request and you see a page, that the response.
Click here for details.
Use HttpClient to connect a site from your mvc controller, click here for details.
Related
In implementing a server Paypal integration, the POST Create call works correctly to https://api.sandbox.paypal.com/v1/payments/payment with the response object matching that found in the API. The server successfully returns the result to the Client, and res.id for the .then(res) function of paypal.request.post is: PAY-76T970067E989851JLPLCMKA
After the user authorizes payment, the client sends a request to my server's execute endpoint with a payload of:
{
"paymentID" : "PAY-76T970067E989851JLPLCMKA",
"payerID" : "3LSD3Q8J7T3ZL"
}
The server then remodels the payload for a query to paypal's POST Execute endpoint as follows:
headers:
Content-Type = "application/json"
Authorization = "Bearer " + accessToken // checked not expired
and a body payload of:
{"payer_id" : "3LSD3Q8J7T3ZL"}
The post is then made to:
https://api.sandbox.paypal.com/v1/payments/payment/PAY-76T970067E989851JLPLCMKA/execute
at which point, the paypal server responds with: The remote server returned an error: (400) Bad Request.
Form what I can see, this matches the API requirements outlined here: https://developer.paypal.com/docs/api/payments/v1/#payment_execute
As a side note, I setup an endpoint on my own server to check the headers and JSON payload being submitted to the Paypal execute endpoint are correct.
Any suggestions would be greatly appreciated.
Resolved: Although the error is being returned when calling the Paypal's Execute endpoint, the problem actually resides in the Create payload. The soft_descriptor property submitted to the Create endpoint must be unique, just like the invoice_number property. Both of these values are found in the Transaction object, as shown here:
https://developer.paypal.com/docs/api/payments/v1/#definition-transaction.
Really, the error should be caught when creating the payment and not when executing it, but, hopefully this helps someone else.
Note to Paypal: A bit more information in the API would have saved a lot of headaches.
I am writing a code to get through authentication to a API based web site. I have the API key that the site needs during the login process. When I call the login method with the API key, it is supposed to redirect to a predefined URL whose parameter will then contain the request token.
e.g on firing the URL in the browser,
https://kite.trade/connect/login?api_key=hcwmefsivttbchla
I am redirected to
https://impacted-purposes.000webhostapp.com/?status=success&request_token=nb0vrfota9ott1r02q153pk3422joruf
(The request token will change in every run)
Notice the request token in the URL on the redirected URL. That's what I need to get from the code.
So, I use a the code that is referred here GetFinalRedirect:
Getting the Redirected URL from the Original URL
ie. I call:
GetFinalRedirect("https://kite.trade/connect/login?api_key=hcwmefsivttbchla")
However, I don't get the final redirect. I understand there could be a Javascript redirect, but checking the response, doesn't suggest so.
Any help pls to get the final URL so that I can parse the request token from it.
Well, I can't test this since i don't have an account. And I hope thats not your real-api-key...
But the function you're using is just sending a HEAD request to server. A HEAD request has no response. With the HEAD request you will only get redirects that are included in the HTTP headers. If the redirect is done with HTML-META tags or with javascript you have to send a GET (or POST) request...
If that fails too set a breakpoint inside the function and look at the received http-headers and the response text...
i am trying to invoke a webservice (WSDL, language:c#) located behind a load balancer.
The load balancer does not accept any http invokation, thus it redirects all HTTP requests to HTTPS.
BTW when I invoke the webservice using the HTTP (it's an old one!) I see the following behavior:
The request is sent to the balancer using HTTP, Request Method: Post;
The balancer's response says redirect to HTTPS;
The Web Service Client sends again the request using HTTPS but the Request Method changes to GET, and it clearly fails!
What is the reason that brings the Request Method to change? Is there any way to make it works?
Thanks!
I want to redirect from www.abc.com to www.xyz.com.
When I redirectd to www.xyz.com at that time how I know about details of GET method of HTTP . so that I come to know this request come from www.abc.com.
As both application hosted on different sever. I tried HTTP Handler for www.xyz.com, but I am unable to get details of HTTP when request method is GET. My handler and module event unable to call at time of redirect.
You can pass hint, for example a parameter saying returnURL=abc.com.
And in the XYZ.com, check for the URL parameter.
Usually when you redirect the request, your header will have the Referrer information which can be retrievable from the target server. For more details about HTTP Referrer please click here
I am integrating with a 3rd party payment platform (Stripe). Their API is posting back a bunch of parameters in the HTTP post to an aspx page. What I need to do is read one of the FORM variables to know where the post should be forwarded to (i.e. it needs to be redirected to the user specific subdomain endpoint - https://user1.mayapp.com/newstripeaccount.aspx).
My questions is how in .NET can you forward the request and preserve all the http post parameters without meticulously parsing them out and using HttpWebRequest to construct a new HTTP post to the final endpoint. Is there a simpler way to redirect and just pass the httpcontext?