Note that there are some explanatory texts on larger screens.

plurals
  1. POCan't upload a photo to Appcelerator Cloud Service using HttpWebRequest in C#
    primarykey
    data
    text
    <p>I'm developing an application in C# that connects to Appcelerator Cloud Service, so far I can make queries and create custom objects, now the problem is when I try to create a photo in ACS. I looked at <a href="https://stackoverflow.com/questions/1874410/webrequest-post-with-both-file-and-parameters">this</a> link and modified my code like this:</p> <pre><code>Image img = pbPhoto.Image; img.Save(Application.StartupPath + "\\tmp.jpg", System.Drawing.Imaging.ImageFormat.Jpeg); //saving the image temporally in hard drive url = "https://api.cloud.appcelerator.com/v1/photos/create.json?key=appkey&amp;_session_id=" + session; HttpWebRequest wrGetUrl = (HttpWebRequest)WebRequest.Create(url); String boundary = "B0unD-Ary"; wrGetUrl.ContentType = "multipart/form-data; boundary=" + boundary; wrGetUrl.Method = "POST"; String postData = "--" + boundary + "\nContent-Disposition: form-data\n\n";; postData += "\n--" + boundary + "\nContent-Disposition: form-data; name=\"file\" filename=\"" + Application.StartupPath + "\\tmp.jpg" + "\"\nContent-Type: image/jpeg\n\n"; byteArray = Encoding.UTF8.GetBytes(postData); byte[] filedata = null; using (BinaryReader readerr = new BinaryReader(File.OpenRead(Application.StartupPath + "\\tmp.jpg"))) filedata = readerr.ReadBytes((int)readerr.BaseStream.Length); wrGetUrl.ContentLength = byteArray.Length + filedata.Length; wrGetUrl.GetRequestStream().Write(byteArray, 0, byteArray.Length); wrGetUrl.GetRequestStream().Write(filedata, 0, filedata.Length); objStream = wrGetUrl.GetResponse().GetResponseStream(); reader = new StreamReader(objStream); </code></pre> <p>I tried this but I got the following error</p> <blockquote> <p>The remote server returned an error: (500) Internal Server Error.</p> </blockquote> <p>I checked my ACS log but the request didn't show up (guess because it was a 500 error). What should I change in my code to upload the photo and crete the photo in ACS? Thanks for any help you may give.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload