1

I am trying to post an image as a staging resource to Facebook. The path for uploading staging resource image is me/staging_resources which works perfectly with the iOS SDK. However, when I try to post the image:

dynamic result = await Client.PostTaskAsync("/me/staging_resources", image);

I am getting an exception in Facebook.DLL telling that the URI is too long (after about 15 seconds). The image object is a dynamic object with a file member which is the byte array of a JPEG file. I've tried lots of other ways of posting the image data but always got different errors about not providing correct image data, and now I'm not getting those errors, it possibly is the way to post the image (it even complained if I didn't make a file member of the object, it explicitly want file to be the binary image data). What could I be doing wrong, and how can I upload a staging resource to Facebook?

Raptor
  • 53,206
  • 45
  • 230
  • 366
Can Poyrazoğlu
  • 33,241
  • 48
  • 191
  • 389
  • Interesting. Can you post more codes ? and what is the full URI ? – Raptor Nov 08 '13 at 02:21
  • the full uri should be https://graph.facebook.com/me/staging_resources as all api calls are made to that endpoint. the only relevant code is that line (image is a dynamic object with file member which is the byte array of the jpeg file), the error originates from within facebook.dll, so if it tries to add something into the URL making it too long, I don't (and can't) know. – Can Poyrazoğlu Nov 08 '13 at 02:24
  • Not sure if [this](http://stackoverflow.com/questions/7043566/invalid-uri-the-uri-string-is-too-long) relates, but seems the "too long" part is that the file content is loaded as Uri, which max character is 2000. – Raptor Nov 08 '13 at 02:31
  • yeah I suspect the same, I'll be investigating this further by downloading the SDK source and stepping through the posttaskasync method. I'll post the results here tomorrow. – Can Poyrazoğlu Nov 08 '13 at 02:39
  • 1
    after investigating into the source, i've found out that the SDK tries to JSON-encode the image file instead of POSTing it. i'm trying to find a solution by understanding the inner workings deeply. this is a bug that should be corrected. – Can Poyrazoğlu Nov 08 '13 at 15:06

1 Answers1

0

Open the WMAppManifest.xml file and search for the tag right after the Tokens declaration.

Try removing the hyphens from the name property of the protocol tag inside the tag. I am assuming you are using a Uri Mapper for your facebook integration.

The tag should look something like below:

<Extensions>
  <Protocol Name="msft-4ff532b5c47f4b42bb68f271cf45f4321" NavUriFragment="encodedLaunchUri=%s" TaskID="_default" />
</Extensions>

The string after the msft is your app id in the windows store.

Oladipo Olasemo
  • 2,010
  • 24
  • 31