D
D
dayover2015-05-14 22:08:45
Layout
dayover, 2015-05-14 22:08:45

C#. Why does the VK API return "photo":"[]"?

I get:

{"server":627329,"photo":"[]","hash":"6ce9e707ba60a464bc45070a748dc9ec"}

private static HttpWebResponse PostMethod()
        {
            string url = "https://api.vk.com/method/photos.getMessagesUploadServer?&v=5.31&access_token=1234";
            WebClient client = new WebClient();
            string json = client.DownloadString(url);
            JavaScriptSerializer json_serializer = new JavaScriptSerializer();
            
            byte[] imageData = client.DownloadData("http://cs5530.vk.me/u43529379/-6/m_b9515ce2.jpg");
            RootObject response = (RootObject)json_serializer.Deserialize(json, typeof(RootObject));
           
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(response.response.upload_url);
            request.Method = "POST";
            request.Credentials = CredentialCache.DefaultCredentials;

            UTF8Encoding encoding = new UTF8Encoding();
            var bytes = encoding.GetBytes(imageData.ToString());

            request.ContentType = "multipart/form-data";
            request.ContentLength = bytes.Length;

            using (var newStream = request.GetRequestStream())
            {
                newStream.Write(bytes, 0, bytes.Length);
                newStream.Close();  
            }
            return (HttpWebResponse)request.GetResponse();
        }

Answer the question

In order to leave comments, you need to log in

5 answer(s)
A
Ankhena, 2018-06-09
@DmitriySwan

input and its absolutely positioned label, all wrapped in a div.
Either outside the label, and inside the span.
Writing "email adress ..." in a pseudo-element is not appropriate.
Something like this: https://jsfiddle.net/m7hcbdrj/ colors, indents change as you need

L
Lander, 2018-06-09
@usdglander

Um... Style the fieldset ?

S
sergey, 2018-06-09
@zorro76

wrap the input in a div and apply pseudo-elements to it to display the caption on top

M
maxsnw, 2018-06-09
@maxsnw

div>span+input and position as you want, or label instead of span

J
Jim_Di, 2015-06-19
@JimDi

Use Fiddler and proxy all requests through it - this will help you quickly understand what the error is.
To get started, try loading the file in the browser on the method page and see how the request is formed in Fiddler, then check how your code works. The error will be visible almost immediately

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question