Search code examples
javaandroidoauthlinkedin-apiscribe

Using the LinkedIn invitation with Scribe and Android


Hi I'm using Scribe to Send a LinkedIn invite, but I'm a little unsure how to use it. I've created the XML body as a string with all the neccessary values inserted but when I make the API call the invite isn't sent. My code is as follows

        invite.setOnClickListener(new Button.OnClickListener() 
        {
            public void onClick (View v) 
            {
                inviteXml = inviteCreator.inviteString(to, subj, body, authName, authValue);

                titleField.setText("");


                call = "http://api.linkedin.com/v1/people/~/mailbox";
                request = new OAuthRequest(Verb.POST, call);
                //request.addPayload(inviteXml);
                request.addBodyParameter("body", inviteXml);
                service.signRequest(accessToken, request);
                response = request.send();
                nameField.setText(response.getBody());
                invite.setVisibility(View.GONE);
            }
        });

on the line request.addPayload(inviteXml); this causes the app to crash. The line request.addBodyParameter("body", inviteXml); returns an error xml message that has a status of 400 with an error code 0 and tht message "Couldn't parse mailbox-item document: error:Unexpected end of file after null"

Am I going about this the wrong way or have I missed something inportant? I've read the LinkedIn documentation but it doesn't seem to say how to add the xml message to the appi call.

Thanks for any help Jeff


Solution

  • Have you tried to specify Content-Lenght and Content-Type ?

    Something like this:

    request.addHeader("Content-Length", Integer.toString(inviteXml.length())); request.addHeader("Content-Type", "text/xml");

    request.addPayload(inviteXml);