You need to sign in to do that
Don't have an account?
Pancho
Get Attachment Content from a Record using Android
Hi,
The Force.com REST API Developer Guide says this is how to download attachement content (on p. 40).
https://na1.salesforce.com/services/data/v20.0/sobjects/Attachment/001D000000INjVe/body -H "Authorization: Bearer token"
In my Android App I am getting an invalid session ID. Any ideas?
I use the REST api to grab the "Body" of the attachmment so I have the URL for the BLOB,
bodyURL = records.getJSONObject(i).getString("Body").toString();
Then I create my URL
imageUrl=client.getClientInfo().instanceUrl+bodyURL+" -H "+'"'+"Authorization: Bearer "+client.getAuthToken()+'"';
Then I try and open the URL and stream it down to put into an ImageView.
URL networkUrl = imageUrl;
try { InputStream in = networkUrl.openConnection().getInputStream(); BufferedInputStream bis = new BufferedInputStream(in,1024*8); ByteArrayOutputStream out = new ByteArrayOutputStream(); int len=0; byte[] buffer = new byte[1024]; while((len = bis.read(buffer)) != -1){ out.write(buffer, 0, len); } out.close(); bis.close(); data = Base64.decode(out.toByteArray(), Base64.DEFAULT); //data = out.toByteArray(); networkBitmap = BitmapFactory.decodeByteArray(data, 0, data.length); } catch (IOException e) { e.printStackTrace(); }
....
ImageView img = (ImageView) findViewById(R.id.imageViewStore); img.setImageBitmap(networkBitmap);
What scopes are associated with the token/ connected app?