function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

Get Attachment Content from a Record using Android


The REST API Developer Guide says this is how to download attachement content (on p. 40). -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 = != -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(;





What scopes are associated with the token/ connected app?