Hello, Why are you trying to create user "by hand"?
Try using Providing API 2.0: http://code.google.com/apis/apps/gdata_provisioning_api_v2.0_reference_dotnet.html#Create_Account_Example Good luck! Pedro On Sat, Sep 20, 2008 at 8:03 AM, Pedro Bastos <[EMAIL PROTECTED]> wrote: > > Hello, > > Why are you trying to create user "by hand"? > > Try using Providing API 2.0: > http://code.google.com/apis/apps/gdata_provisioning_api_v2.0_reference_dotnet.html#Create_Account_Example > > Good luck! > > Pedro > > On Sat, Sep 20, 2008 at 3:51 AM, steve_t <[EMAIL PROTECTED]> wrote: >> >> Hello out there I need some help. I'm trying add a new user using the >> Provisioning API. My program is in VB.NET. When My program trys to >> post the Xml code to Google I get this error: >> >> "The remote server returned an error: (400) Bad Request. >> Description: An unhandled exception occurred during the execution of >> the current web request. Please review the stack trace for more >> information about the error and where it originated in the code. >> >> Exception Details: System.Net.WebException: The remote server returned >> an error: (400) Bad Request." >> >> >> Would someone tell me what I'm doing wrong; Here is my code below, Any >> help would be much appreciated. Thank you... >> >> Dim strDataToPost As String >> Dim myWebRequest As WebRequest >> Dim myRequestStream As Stream >> Dim myStreamWriter As StreamWriter >> Dim myWebResponse As WebResponse >> Dim myResponseStream As Stream >> Dim myStreamReader As StreamReader >> Dim Tokens As String >> Dim strToken() As String >> Dim strAuth As String >> >> '======================Get Auth >> Token========================================= >> myWebRequest = WebRequest.Create( _ >> "https://www.google.com/accounts/ClientLogin") >> >> With myWebRequest >> .Method = "POST" >> .ContentType = "application/x-www-form-urlencoded" >> End With >> >> strDataToPost = >> "[EMAIL PROTECTED]&Passwd=PASS&accountType=HOSTED&service=apps" >> >> myRequestStream = myWebRequest.GetRequestStream() >> myStreamWriter = New StreamWriter(myRequestStream) >> myStreamWriter.Write(strDataToPost) >> myStreamWriter.Flush() >> myStreamWriter.Close() >> myRequestStream.Close() >> myWebResponse = myWebRequest.GetResponse() >> myResponseStream = myWebResponse.GetResponseStream() >> myStreamReader = New StreamReader(myResponseStream) >> Tokens = myStreamReader.ReadToEnd() >> strToken = Split(Tokens, "Auth=") >> strAuth = RTrim(strToken(1)) >> myStreamReader.Close() >> myResponseStream.Close() >> myWebResponse.Close() >> >> '========================Create Xml >> File======================================= >> Dim XmlFile As String = >> Path.Combine(Request.PhysicalApplicationPath, _ >> "newuser.xml") >> Dim fs As New FileStream(XmlFile, FileMode.Create) >> Dim w As New XmlTextWriter(fs, Nothing) >> >> w.WriteStartDocument() >> >> w.WriteStartElement("atom:entry") >> w.WriteAttributeString("xmlns:atom", Nothing, "http:// >> www.w3.org/2005/Atom") >> w.WriteAttributeString("xmlns:apps", Nothing, "http:// >> schemas.google.com/apps/2006") >> >> w.WriteStartElement("atom:category") >> w.WriteAttributeString("scheme", Nothing, "http:// >> schemas.google.com/g/2005#kind") >> w.WriteAttributeString("term", Nothing, "http:// >> schemas.google.com/apps/2006#user") >> w.WriteEndElement() >> >> w.WriteStartElement("apps:login") >> w.WriteAttributeString("userName", Nothing, "SusanJones-1321") >> w.WriteAttributeString("password", Nothing, "123$$abc") >> w.WriteAttributeString("suspended", Nothing, "false") >> w.WriteEndElement() >> >> w.WriteStartElement("apps:quota") >> w.WriteAttributeString("limit", Nothing, "2048") >> w.WriteEndElement() >> >> w.WriteStartElement("apps:name") >> w.WriteAttributeString("familyName", Nothing, "Jones") >> w.WriteAttributeString("givenName", Nothing, "Susan") >> w.WriteEndElement() >> >> w.WriteEndElement() >> >> w.WriteEndDocument() >> w.Close() >> >> '=======================POST Xml File to >> Google=================================== >> Dim xmlData As String = >> Path.Combine(Request.PhysicalApplicationPath, _ >> "newuser.xml") >> Dim xmlStream As New FileStream(xmlData, FileMode.Open) >> Dim rq As HttpWebRequest >> rq = HttpWebRequest.Create("https://apps-apis.google.com/a/ >> feeds/oneworldcity.com/user/2.0") >> With rq >> rq.Method = "POST" >> rq.ContentType = "application/atom+xml" >> .Headers.Add(HttpRequestHeader.Authorization, "GoogleLogin >> auth=" & strAuth) >> Dim s As Stream = rq.GetRequestStream() >> Dim sw As StreamWriter = New StreamWriter(s) >> sw.Write(xmlStream) >> sw.Flush() >> sw.Close() >> End With >> rq.GetResponse() >> File.Delete(xmlData) >> >> > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Google Apps APIs" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/google-apps-apis?hl=en -~----------~----~----~----~------~----~------~--~---
