How to get JSON back from HTTP POST Request (to another domain)

Posted by roman m on Stack Overflow See other posts from Stack Overflow or by roman m
Published on 2009-06-24T21:53:57Z Indexed on 2010/04/06 12:33 UTC
Read the original article Hit count: 309

Filed under:
|
|
|
|

I'm trying to use the API on a website, here's the part of the manual:

Authenticated Sessions (taken from here)

To create an authenticated session, you need to request an authToken from the '/auth' API resource.

  • URL: http://stage.amee.com/auth (this is not my domain)
  • Method: POST
  • Request format: application/x-www-form-urlencoded
  • Response format: application/xml, application/json
  • Response code: 200 OK
  • Response body: Details of the authenticated user, including API version.
  • Extra data: "authToken" cookie and header, containing the authentication token that should be used for subsequent calls.

    Parameters: username / password

Example

Request

POST /auth HTTP/1.1
Accept: application/xml
Content-Type: application/x-www-form-urlencoded

username=my_username&password=my_password

Response

HTTP/1.1 200 OK Set-Cookie: authToken=1KVARbypAjxLGViZ0Cg+UskZEHmqVkhx/Pm...;
authToken: 1KVARbypAjxLGViZ0Cg+UskZEHmqVkhx/PmEvzkPGp...==
Content-Type: application/xml; charset=UTF-8

QUESTION:

How do I get that to work?

I tried jQuery, but it seems to have problem with XSS. Actual code snippet would be greatly appreciated.

p.s.

All I was looking for was WebClient class in C#

© Stack Overflow or respective owner

Related posts about api

Related posts about request