views:

25

answers:

1

I'm going to try to use the WebClient object in .NET to grab the response querystring values sent back by the resource.

I'm familiar with grabbing xml, json, etc. but typically I haven't worked with many NVP type of APIs in terms of grabbing the query immediately from an response sent back from a resource server-side. So how is a query sent back, in the body of a response, header, what? How do you grab it, with the stream object just like you do anything else?

This questions relates to the environment I work in C# but really it relates to the web as a whole as well which is why I tagged this in multiple categories as a Request/Response is not MS specific however I am also at the same time trying to utilize the .NET WebClient object.

+1  A: 

Responses don't have query strings... requests do, and they're part of the URL.

If that doesn't help, please give us an example of how you'd get the query string of a response, and we'll see if we can understand what you mean.

Jon Skeet
Ok, Facebook sends back an access token in the response...I need to grab it.
CoffeeAddict
I don't think it's json...but I guess it could be like all the rest in that API.
CoffeeAddict
I knew requests do but figured servers could also send their own somehow back in a response outside of just data like xml, json, etc.
CoffeeAddict
Ok it says use the access token returned by the request...I don't get it, requests don't return anything, responses do. So I make a request to http://graph.facebook.com/access_token?code="the token here"...etc. which is requesting them to send me a token back based on the verification code I received earlier and they say to grab the
CoffeeAddict
@CoffeeAddict: It says to send the token that you retrieved on a previous call to `https://graph.facebook.com/oauth/access_token`. I admit it's not terribly clear, but I don't see anything to suggest the token would be in a "response query string". Web responses basically consist of headers and a body.
Jon Skeet
you send the verification code to them not the token so for example it would be https://graph.facebook.com/oauth/access_token?code=verificationCodeReceivedFromPreviousRequest. When their resource receives the HttpRequest they check that token which tells them that yes, this user has authed and so lets send back the client a token so the client can now make API calls on behalf of the user. So What I'm confused about is how can you get back a token in a request when you just made a request?
CoffeeAddict
@CoffeeAddict You make your first request. The response returns json which you will have to parse. Inside that json data you'll find a token, you need to use that token to construct the next request you make.
nos
I wanted to edit the last comment I made but couldn't so next reply is a reformatted response
CoffeeAddict
CoffeeAddict
Ok, yea. I mean I just thought for some reason by the way they phrased that ...that they were sending us an Http Response back with querystring values which makes no sense..that's not possible. It's just json like the rest of the data types they send back. Thanks.
CoffeeAddict