Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion How to send Token Request?
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Ellen  
View profile  
 More options Sep 16 2010, 12:07 pm
From: Ellen <ellen.hu...@gmail.com>
Date: Thu, 16 Sep 2010 09:07:36 -0700 (PDT)
Local: Thurs, Sep 16 2010 12:07 pm
Subject: Re: How to send Token Request?
Hi Marcelo,

I used code below, but I had the error says "The remote server
returned an error: (400) Bad Request." It means the call reached the
server, but since the request does not succeed,  Do you think if there
are some security reasons prevent me from accessing or my credential
didn't match? Thank you in advance for your help.

WebRequest req = null;
 WebResponse rsp = null;
try {

                string xml = "<?xml version=\"1.0\" encoding=
\"UTF-8\"? ><auth_request><user><email>j...@yourcause.com</
email><password>8005case</password></user><api_key>aada3015-2f84-4eab-
bf00-4d5315fe2b05</api_key></ auth_request>";
               string uri = "https://api-test.globalgiving.org/api/
userservice/tokens";
               req = WebRequest.Create(uri);
               req.Method = "POST";        // Post method
               req.ContentType = "text/xml";

               byte[] bytes =
System.Text.Encoding.ASCII.GetBytes(xml);

               req.ContentLength = bytes.Length;

               Stream outputStream = req.GetRequestStream();
               outputStream.Write(bytes, 0, bytes.Length);
               outputStream.Close();
               rsp = req.GetResponse();
               Stream MyStream = rsp.GetResponseStream();
               StreamReader myStreamReader = new
StreamReader(MyStream);
               myStreamReader.ReadToEnd().Trim();

            }

            catch (WebException ex) {
                throw new WebException("Failed to get the request
stream.", ex);

            }
            catch (Exception e) {
                throw new Exception("Failed to get the request
stream.", e);

            }
            finally {
               if (req != null) req.GetRequestStream().Close();
               if (rsp != null) rsp.GetResponseStream().Close();
            }

Ellen

On Sep 15, 8:23 am, Ellen <ellen.hu...@gmail.com> wrote:

> Thank you very much for your quick response, Marcelo!

> It really helps.

> Ellen


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.