{"id":1628,"date":"2022-08-30T15:18:07","date_gmt":"2022-08-30T15:18:07","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2013\/11\/27\/i-am-trying-to-upload-an-image-to-facebook-but-get-key-format-expected-byte-collection-of-common-programming-errors\/"},"modified":"2022-08-30T15:18:07","modified_gmt":"2022-08-30T15:18:07","slug":"i-am-trying-to-upload-an-image-to-facebook-but-get-key-format-expected-byte-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2022\/08\/30\/i-am-trying-to-upload-an-image-to-facebook-but-get-key-format-expected-byte-collection-of-common-programming-errors\/","title":{"rendered":"I am trying to upload an image to Facebook but get &ldquo;Key format expected byte[]&rdquo;-Collection of common programming errors"},"content":{"rendered":"<p>I am using Facebook&#8217;s API to create a new album with a picture from my android app but I keep on getting these annoying errors that make no sense. I have done some research but have come up with nothing. Please help!<\/p>\n<pre><code>String albumName = ((TextView)findViewById(R.id.album_name)).getText().toString();\nBundle params = new Bundle();\nparams.putByteArray(\"pictures\", toByteArray(mediaPath[0])); \nparams.putString(\"name\", albumName);\nrequest.request(\"https:\/\/graph.facebook.com\/me\/albums\",params,\"POST\", new UploadListener(), new Object());\n<\/code><\/pre>\n<p>Take a look at my log cat<\/p>\n<blockquote>\n<p>01-26 15:51:50.501: W\/Bundle(616): Key format expected byte[] but value was a java.lang.String. The default value was returned. 01-26 16:07:48.871: D\/Facebook-Util(670): POST URL: https:\/\/graph.facebook.com\/https:\/\/graph.facebook.com\/me\/albums 01-26 16:07:48.891: W\/Bundle(670): Key format expected byte[] but value was a java.lang.String. The default value was returned. 01-26 16:07:48.891: W\/Bundle(670): Attempt to cast generated internal exception: 01-26 16:07:48.891: W\/Bundle(670): java.lang.ClassCastException: java.lang.String 01-26 16:07:48.891: W\/Bundle(670): at android.os.Bundle.getByteArray(Bundle.java:1305) 01-26 16:07:48.891: W\/Bundle(670): at com.facebook.android.Util.openUrl(Util.java:155) 01-26 16:07:48.891: W\/Bundle(670): at com.facebook.android.Facebook.request(Facebook.java:717) 01-26 16:07:48.891: W\/Bundle(670): at com.facebook.android.AsyncFacebookRunner$2.run(AsyncFacebookRunner.java:253) 01-26 16:07:49.390: D\/dalvikvm(670): GC_CONCURRENT freed 2526K, 57% free 4489K\/10311K, external 5789K\/6493K, paused 5ms+4ms 01-26 16:07:49.560: W\/Bundle(670): Key method expected byte[] but value was a java.lang.String. The default value was returned. 01-26 16:07:49.560: W\/Bundle(670): Attempt to cast generated internal exception: 01-26 16:07:49.560: W\/Bundle(670): java.lang.ClassCastException: java.lang.String 01-26 16:07:49.560: W\/Bundle(670): at android.os.Bundle.getByteArray(Bundle.java:1305) 01-26 16:07:49.560: W\/Bundle(670): at com.facebook.android.Util.encodePostBody(Util.java:63) 01-26 16:07:49.560: W\/Bundle(670): at com.facebook.android.Util.openUrl(Util.java:182) 01-26 16:07:49.560: W\/Bundle(670): at com.facebook.android.Facebook.request(Facebook.java:717) 01-26 16:07:49.560: W\/Bundle(670): at com.facebook.android.AsyncFacebookRunner$2.run(AsyncFacebookRunner.java:253) 01-26 16:07:49.570: W\/Bundle(670): Key format expected byte[] but value was a java.lang.String. The default value was returned. 01-26 16:07:49.570: W\/Bundle(670): Attempt to cast generated internal exception: 01-26 16:07:49.570: W\/Bundle(670): java.lang.ClassCastException: java.lang.String 01-26 16:07:49.570: W\/Bundle(670): at android.os.Bundle.getByteArray(Bundle.java:1305) 01-26 16:07:49.570: W\/Bundle(670): at com.facebook.android.Util.encodePostBody(Util.java:63) 01-26 16:07:49.570: W\/Bundle(670): at com.facebook.android.Util.openUrl(Util.java:182) 01-26 16:07:49.570: W\/Bundle(670): at com.facebook.android.Facebook.request(Facebook.java:717) 01-26 16:07:49.570: W\/Bundle(670): at com.facebook.android.AsyncFacebookRunner$2.run(AsyncFacebookRunner.java:253) 01-26 16:07:49.610: D\/dalvikvm(670): GC_FOR_MALLOC freed 258K, 57% free 4445K\/10311K, external 5789K\/6493K, paused 38ms 01-26 16:07:49.620: I\/dalvikvm-heap(670): Grow heap (frag case) to 15.307MB for 2903026-byte allocation 01-26 16:07:49.670: D\/dalvikvm(670): GC_FOR_MALLOC freed<\/p>\n<\/blockquote>\n<p id=\"rop\"><small>Originally posted 2013-11-27 12:09:36. <\/small><\/p>","protected":false},"excerpt":{"rendered":"<p>I am using Facebook&#8217;s API to create a new album with a picture from my android app but I keep on getting these annoying errors that make no sense. I have done some research but have come up with nothing. Please help! String albumName = ((TextView)findViewById(R.id.album_name)).getText().toString(); Bundle params = new Bundle(); params.putByteArray(&#8220;pictures&#8221;, toByteArray(mediaPath[0])); params.putString(&#8220;name&#8221;, albumName); [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1628","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/1628","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=1628"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/1628\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=1628"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=1628"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=1628"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}