6 messages in com.googlegroups.google-finance-apis[Google Finance APIs] Re: Pls help. P...
FromSent OnAttachments
VPNNov 7, 2008 5:41 am 
Doug ChimentoNov 7, 2008 8:48 am 
SBNov 8, 2008 1:00 am 
Doug ChimentoNov 8, 2008 12:56 pm 
salaja K BalakrishnanNov 9, 2008 3:09 am 
salaja K BalakrishnanNov 9, 2008 5:05 am 
Actions with this message:
Paste this link in email or IM:
Paste this link in email or IM:
Atom feed for this thread
Paste this URL into your reader:
Subject:[Google Finance APIs] Re: Pls help. Portfolio add -> (400) Bad RequestActions...
From:salaja K Balakrishnan (sala@gmail.com)
Date:Nov 9, 2008 3:09:22 am
List:com.googlegroups.google-finance-apis

I am using the atom format you have send and I still get the same error. Please find attached the code to generate the Portfolio.

When trying to get webrequest.GetRequestStream() the following stack is shown:

- stOut {System.Net.ConnectStream} System.IO.Stream {System.Net.ConnectStream} + [System.Net.ConnectStream] {System.Net.ConnectStream} System.Net.ConnectStream + base {System.Net.ConnectStream} System.MarshalByRefObject {System.Net.ConnectStream} CanRead false bool CanSeek false bool CanTimeout true bool CanWrite true bool - Length 'stOut.Length' threw an exception of type 'System.NotSupportedException' long {System.NotSupportedException} + base {"This stream does not support seek operations."} System.SystemException {System.NotSupportedException} - Position 'stOut.Position' threw an exception of type 'System.NotSupportedException' long {System.NotSupportedException} + base {"This stream does not support seek operations."} System.SystemException {System.NotSupportedException} ReadTimeout 300000 int WriteTimeout 300000 int + Static members + Non-Public members

Please guide.

Thanks,

SB

On Sun, Nov 9, 2008 at 2:27 AM, Doug Chimento <dchi@gmail.com> wrote:

That doesn't look like the correct atom format. It should be something like <atom:entry xmlns:atom="http://www.w3.org/2005/Atom"> <atom:category term="http://schemas.google.com/finance/2007#portfolio" scheme="http://schemas.google.com/g/2005#kind"/> <atom:title type="text">test</atom:title> <gf:portfolioData xmlns:gf="http://schemas.google.com/finance/2007" currencyCode="USD"/> </atom:entry>

On Sat, Nov 8, 2008 at 4:01 AM, SB <sala@gmail.com> wrote:

The XML I am sending to the URL is

<entry> <title type='text'>A New Portfolio</title> <gf:portfolioData currencyCode='USD'/> </entry>

String strATOMRequestBody = HttpUtility.UrlEncode("<entry xmlns:gf= \"http://schemas.google.com/finance/2007\<http://schemas.google.com/finance/2007/>" " + "<title type=\"text\">A New Portfolio</title>" + "<gf:portfolioData currencyCode=\"USD\"/ >" + "</entry>", Encoding.UTF8);

On Nov 7, 9:48 pm, "Doug Chimento" <dchi@gmail.com> wrote:

Can you provide the XML you are sending to the google servers?

On Fri, Nov 7, 2008 at 8:42 AM, VPN <vino@gmail.com> wrote:

Ref:

http://code.google.com/apis/finance/developers_guide_protocol.html

The Create Portfolio is resulting in a :- "{"The remote server returned an error: (400) Bad Request."}" exception - For the .NET client library.

Other like retrieval operations works perfectly fine.

What am I doing wrong?. Please guide. Thanks in Advance.- Hide quoted text -

- Show quoted text -

--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups
"Google Finance APIs and Tools" group. To post to this group, send email to goog@googlegroups.com To unsubscribe from this group, send email to
google-finance-apis+unsu@googlegroups.com For more options, visit this group at
http://groups.google.com/group/google-finance-apis?hl=en -~----------~----~----~----~------~----~------~--~---

public static void getCreatePortfolios() { //reference:
http://code.google.com/apis/finance/developers_guide_protocol.html

HttpWebRequest webrequest =
(HttpWebRequest)WebRequest.Create("http://finance.google.com/finance/feeds/default/portfolios");

webrequest.KeepAlive = false; webrequest.Method = "POST"; webrequest.ContentType = "application/atom+xml; charset=ASCII";

//Proxy setting SetProxy();

Authenticate auth = new Authenticate(); auth.email =
System.Configuration.ConfigurationSettings.AppSettings["email"]; auth.password =
System.Configuration.ConfigurationSettings.AppSettings["password"]; ;

String token = auth.authenticate();

String DEVELOPER_KEY =
System.Configuration.ConfigurationSettings.AppSettings["Developers_key"];

webrequest.Headers.Add("Authorization", "GoogleLogin auth=" +
token); webrequest.Headers.Add("X-Google-Key", "key=" + DEVELOPER_KEY);

StringBuilder XMLFeed = new StringBuilder(); XMLFeed.Append(@"<atom:entry
xmlns:atom='http://www.w3.org/2005/Atom'> <atom:category
term='http://schemas.google.com/finance/2007#portfolio' scheme='http://schemas.google.com/g/2005#kind'/> <atom:title
type='text'>test_1</atom:title> <gf:portfolioData xmlns:gf='http://schemas.google.com/finance/2007'
currencyCode='USD'/></atom:entry>");

webrequest.ContentLength = XMLFeed.Length; System.Text.Encoding enc = System.Text.Encoding.ASCII; byte[] bytearrray = enc.GetBytes(Convert.ToString(XMLFeed));

//write the request

using (Stream stOut = webrequest.GetRequestStream()) { stOut.Write(bytearrray, 0, bytearrray.Length); }

using (HttpWebResponse response =
(HttpWebResponse)webrequest.GetResponse()) { if (response.StatusCode != HttpStatusCode.OK) { string msg = String.Format("POST failed. Received HTTP {0}",
response.StatusCode); throw new ApplicationException(msg); } }