Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6839831
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:46:01+00:00 2026-05-26T23:46:01+00:00

I am new to Windows Phone 7 application development. I am trying to call

  • 0

I am new to Windows Phone 7 application development. I am trying to call a URL in my program using POST method which takes some parameters. After the successful post I am supposed to get the response in JSON format. But I am not getting the response. The code I am using is:

    public void Submit()
    {
        // Prepare web request...
        HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(new Uri(someUrl, UriKind.Absolute));
        myRequest.Method = "POST";
        myRequest.ContentType = string.Format("multipart/form-data; boundary={0}", boundary);

        myRequest.BeginGetRequestStream(new AsyncCallback(GetRequestStreamCallback), myRequest);
    }


    public string url { get; set; }
    private Dictionary<string, string> _parameters = new Dictionary<string, string>();

    public Dictionary<string, string> parameters
    {
        get { return _parameters; }
        set { _parameters = value; }
    }

    string boundary = "----------" + DateTime.Now.Ticks.ToString();


    private void GetRequestStreamCallback(IAsyncResult asynchronousResult)
    {
        HttpWebRequest request = (HttpWebRequest)asynchronousResult.AsyncState;
        Stream postStream = request.EndGetRequestStream(asynchronousResult);
        parameters.Add("userid", "0");
        parameters.Add("locationid", "0");
        writeMultipartObject(postStream, parameters);
        postStream.Close();

        request.BeginGetResponse(new AsyncCallback(GetResponseCallback), request);
    }

    private void GetResponseCallback(IAsyncResult asynchronousResult)
    {
        HttpWebRequest request = (HttpWebRequest)asynchronousResult.AsyncState;
        HttpWebResponse response = (HttpWebResponse)request.EndGetResponse(asynchronousResult);
        Stream streamResponse = response.GetResponseStream();
        StreamReader streamRead = new StreamReader(streamResponse);
        streamResponse.Close();
        streamRead.Close();
        // Release the HttpWebResponse
        response.Close();
    }

    public void writeMultipartObject(Stream stream, object data)
    {
        StreamWriter writer = new StreamWriter(stream);
        if (data != null)
        {
            foreach (var entry in data as Dictionary<string, string>)
            {
                WriteEntry(writer, entry.Key, entry.Value);
            }
        }
        writer.Write("--");
        writer.Write(boundary);
        writer.WriteLine("--");
        writer.Flush();
    }

    private void WriteEntry(StreamWriter writer, string key, object value)
    {
        if (value != null)
        {
            writer.Write("--");
            writer.WriteLine(boundary);
            if (value is byte[])
            {
                byte[] ba = value as byte[];

                writer.WriteLine(@"Content-Disposition: form-data; name=""{0}""; filename=""{1}""", key, "sentPhoto.jpg");
                writer.WriteLine(@"Content-Type: application/octet-stream");
                //writer.WriteLine(@"Content-Type: image / jpeg");
                writer.WriteLine(@"Content-Length: " + ba.Length);
                writer.WriteLine();
                writer.Flush();
                Stream output = writer.BaseStream;

                output.Write(ba, 0, ba.Length);
                output.Flush();
                writer.WriteLine();
            }
            else
            {
                writer.WriteLine(@"Content-Disposition: form-data; name=""{0}""", key);
                writer.WriteLine();
                writer.WriteLine(value.ToString());
            }
        }
    }

I cannot find what the real problem is. Anybody out there to help me out?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T23:46:01+00:00Added an answer on May 26, 2026 at 11:46 pm

    I got the solution as:

       {
            Dictionary<string, object> param = new Dictionary<string, object>();
            param.Add(DataHolder.USER_ID, "0");
            param.Add(DataHolder.DEFAULT_LOCATION_ID, "0");
            PostClient proxy = new PostClient(param);
            proxy.DownloadStringCompleted += new PostClient.DownloadStringCompletedHandler(proxy_DownloadStringCompleted);           
            proxy.DownloadStringAsync(new Uri(DataHolder.mainConfigFetchUrl, UriKind.Absolute));
    
    
    
    
    
        }
    
        void proxy_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
        {
            if (e.Error == null)
            {
                //Process the result... 
                string data = e.Result;
            }
        }
    

    For PostClient we will need a WindowsPhonePostClient.dll which can be obtained from http://postclient.codeplex.com/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am new to Windows Phone 7 application development. Can we create different views
I am developing Windows Phone 7 application which read some text and speak the
I am using Ninject with Windows Phone application. My logic includes IBarViewModel interface which
I am new to windows phone 7 development platform.I am trying to do validation
I am using Silverlight to develop a Windows Phone 7 application. My requirement is
I'm using MVVM Light to build a WP7 (Windows Phone 7) application. I wish
I am new in windows phone development. Now I am developing a windows phone
I am developing an application for Windows Phone 7. I am trying to use
I have a windows phone 7 application where I´m using a DatePicker from the
Am making an application in WP7 using Windows Phone SDK 7.1 / C# Am

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.