title: Post a message to LinkedIn with Scribe in not working in Android
body: <p>Below is the code to send a post message. On my screen i have an EditText section to allow the user to enter text and when they hit post the sendMessage function is called. I keep getting this in the response. I have also tried URLEncode.encode(payload, "UTF-8") to get an encoded string to add to the body and that did not work. Any insight would be helpful.</p>
  
  <pre><code>04-19 18:24:50.570: D/response(693): &lt;error&gt;
  04-19 18:24:50.570: D/response(693):   &lt;status&gt;400&lt;/status&gt;
  04-19 18:24:50.570: D/response(693):   &lt;timestamp&gt;1334859891007&lt;/timestamp&gt;
  04-19 18:24:50.570: D/response(693):   &lt;request-id&gt;WJPI8VXQME&lt;/request-id&gt;
  04-19 18:24:50.570: D/response(693):   &lt;error-code&gt;0&lt;/error-code&gt;
  04-19 18:24:50.570: D/response(693):   &lt;message&gt;Couldn't parse share document: error: Unexpected end of file after null&lt;/message&gt;
  04-19 18:24:50.570: D/response(693): &lt;/error&gt;
  </code></pre>
  
  <p>Here is the code:</p>
  
  <pre><code>private static final String SendMessage = "https://api.linkedin.com/v1/people/~/shares";
  
  public void sendMessage(View view)
  {
      //Get works just fine
      //OAuthRequest req = new OAuthRequest(Verb.GET, "http://api.linkedin.com/v1/people/~/connections:(id,last-name)");
      //service.signRequest(accessToken, req);
      //Response res = req.send();
      //Log.e("get", res.getBody());
  
      OAuthRequest post = new OAuthRequest(Verb.POST, SendMessage);
  
      //Have also  tried adding &lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;" to the beginning of the payload string        
      String payload = "&lt;share&gt;" +
                          "&lt;comment&gt;testing&lt;/comment&gt;" +
                          "&lt;visibility&gt;&lt;code&gt;anyone&lt;/code&gt;&lt;/visibility&gt;" +
                       "&lt;/share&gt;";
  
      post.addBodyParameter("body", payload);
      post.addHeader("Content-Type", "text/xml;charset=UTF-8");
  
      service.signRequest(accessToken, post);
      try
      {
          Response response = post.send();
          Log.d("response",response.getBody());
      }
      catch (Exception e)
      {
          e.printStackTrace();
      }
      LinkedInActivity.this.finish();
  }
  </code></pre>
  
  <p>and my service is being defined as:</p>
  
  <pre><code>service = new ServiceBuilder()
                  .provider(LinkedInApi.class)
                  .apiKey(API_KEY)
                  .apiSecret(API_SEC)
                  .callback(CALLBACK)
                  .debug()
                  .build();
  
  final Token requestToken = service.getRequestToken();
  final String authURL = service.getAuthorizationUrl(requestToken);
  </code></pre>
  
  <p>I use a webview to catch the callback to save the verifier/token.  Example is below:</p>
  
  <pre><code>webView.setWebViewClient(new WebViewClient()
      {
          @Override
          public boolean shouldOverrideUrlLoading(WebView view, String url) {
  
              if(url.startsWith("oauth")){
                  webView.setVisibility(View.GONE);
  
                  Uri uri = Uri.parse(url);
                  String verifier = uri.getQueryParameter("oauth_verifier");
                  Verifier v = new Verifier(verifier);
  
                  //save token
                  accessToken = service.getAccessToken(requestToken, v);
  
                  if(uri.getHost().equals("linkedIn")){
                      editText.setText(appState.socialMediaMessage);
                      //place the cursor at the end of the predefined text
                      editText.setSelection(editText.getText().length());
  
                      textLimit = textLimit - editText.length();
                      textView.setText(String.valueOf(textLimit));
  
                  }
  
                  return true;
              }
  
              return super.shouldOverrideUrlLoading(view, url);
          }
      });
  
      //send user to authorization page
      webView.loadUrl(authURL);
  </code></pre>