Hi Alain,

Can you share with us the part of your code that creates the contact? I am
> not an expert in VB.NET <http://vb.net/>, but I might find the issue by
> reading your code.
>

the dotnetopenauth code is based on the example 'PostBlogEntry' included in
the dotnetopenauth-download. The 'PostBlogEntry' works well, I could create
a new blog entry from my application. So I just changed the XML and the URL
but then I only get '(400) Bad Request'. Hope you have any idea....

 Public Shared Sub AddNewContact(ByVal consumer As
DotNetOpenAuth.OAuth.ConsumerBase, ByVal accessToken As String)
        Dim feedUrl As String = "
https://www.google.com/m8/feeds/contacts/default/full";

        Dim Atom As XNamespace = "http://www.w3.org/2005/Atom";
        Dim Gd As XNamespace = "http://schemas.google.com/g/2005";
        Dim entry As XElement
        entry = New XElement(Atom + "entry", _
                    New XAttribute(XNamespace.Xmlns + "atom",
Atom.NamespaceName), _
                    New XAttribute(XNamespace.Xmlns + "gd",
Gd.NamespaceName), _
                    New XElement(Atom + "category", _
                            New XAttribute("scheme", "
http://schemas.google.com/g/2005#kind";), _
                            New XAttribute("term", "
http://schemas.google.com/contact/2008#contact";)), _
                    New XElement(Gd + "name", _
                            New XElement(Gd + "givenName", "Elizabeth"), _
                            New XElement(Gd + "familyName", "Bennet"), _
                            New XElement(Gd + "fullName", "Elizabeth
Bennet")))

        Dim ms As New IO.MemoryStream()
        Dim xws As New System.Xml.XmlWriterSettings()
        xws.Encoding = Encoding.UTF8
        Dim xw As System.Xml.XmlWriter = System.Xml.XmlWriter.Create(ms,
xws)
        entry.WriteTo(xw)
        xw.Flush()

        Dim request As Net.WebRequest = consumer.PrepareAuthorizedRequest( _
                New DotNetOpenAuth.Messaging.MessageReceivingEndpoint( _
                    feedUrl,
DotNetOpenAuth.Messaging.HttpDeliveryMethods.PostRequest Or _

DotNetOpenAuth.Messaging.HttpDeliveryMethods.AuthorizationHeaderRequest),
accessToken)
        request.ContentType = "application/atom+xml"
        request.Method = "POST"
        request.ContentLength = ms.Length
        ms.Seek(0, IO.SeekOrigin.Begin)
        Using requestStream As IO.Stream = request.GetRequestStream()
            ms.CopyTo(requestStream)
        End Using
        Using response As Net.HttpWebResponse =
DirectCast(request.GetResponse(), Net.HttpWebResponse)
            ' Success
            If response.StatusCode = Net.HttpStatusCode.Created Then
                ' Error!
            Else
            End If
        End Using

    End Sub

On Mon, Aug 1, 2011 at 6:27 PM, Alain Vongsouvanh <[email protected]> wrote:

> Hello Kai,
>
> Can you share with us the part of your code that creates the contact? I am
> not an expert in VB.NET, but I might find the issue by reading your code.
> Also, have you considered using the .NET GData client library? There is a
> developer's guide in C# but I believe converting the code to VB shouldn't be
> so hard:
>
> http://code.google.com/intl/en/apis/contacts/docs/3.0/developers_guide.html#Creating
>
> Best,
> Alain
>
> On Sat, Jul 30, 2011 at 2:39 AM, Kai <[email protected]> wrote:
>
>> Hi Alain,
>>
>> played around a bit more: When I revoke access for my app in my google
>> user profile then I get (403) forbidden, also when I use a wrong email
>> address instead of 'default' in the URL I also get (as expected) (403)
>> forbidden. But as soon as I use 'default' or my email address (url-encoded
>> using '%40' as @) I get (400) Bad Request. So it seems that my authorization
>> works correct, but something in the request is wrong....
>>
>>  --
>> You received this message because you are subscribed to the Google
>> Groups "Google Contacts, Shared Contacts and User Profiles 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://code.google.com/apis/contacts/community/forum.html
>>
>
>
>
> --
> Alain Vongsouvanh
>
>
>
>  --
> You received this message because you are subscribed to the Google
> Groups "Google Contacts, Shared Contacts and User Profiles 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://code.google.com/apis/contacts/community/forum.html
>

-- 
You received this message because you are subscribed to the Google
Groups "Google Contacts, Shared Contacts and User Profiles 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://code.google.com/apis/contacts/community/forum.html

Reply via email to