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

  • SEARCH
  • Home
  • 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 6117547
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T15:19:59+00:00 2026-05-23T15:19:59+00:00

Below is the code for titanium: var request = Titanium.Network.createHTTPClient(); request.open(POST, bh.serverAddress + MyCareer.svc/PostMessage/+

  • 0

Below is the code for titanium:

var request = Titanium.Network.createHTTPClient();

        request.open("POST", bh.serverAddress + "MyCareer.svc/PostMessage/"+ bh.userID + "/" + bh.logic.profile.userID);
        request.setRequestHeader("enctype", "multipart/form-data");
        request.setRequestHeader("Content-Type", "text/json");
        request.send(data_to_send); 
        request.onload = function() {
            Ti.API.info(this.responseText); 
            bh.ui.profile.createWindow();
        };
        request.onerror = function(){
            alert('Error while posting message');
        };

Below is the code for WCF:

Interface:

[OperationContract]
        [WebInvoke(Method = "POST", 
                        UriTemplate = "/PostMessage/{userid}/{touserid}", 
                        BodyStyle = WebMessageBodyStyle.WrappedRequest,
            ResponseFormat = WebMessageFormat.Json,
            RequestFormat = WebMessageFormat.Json)]
        int PostMessage(string userid, string touserid, string message);

Class:

public int PostMessage(string userID, string toUserID, string message)
        {
            MDBDataContext oMDB = new MDBDataContext();
            int returnValue = oMDB.PostMessage(Convert.ToInt32(userID), message, Convert.ToInt32(toUserID));

            oMDB.Dispose();

            return returnValue;
        }

Query: If i convert this functionality to “GET” than it works very fine. But, with “POST” i get error and i am unable to figure out the error. I have enable traceListener also for WCF, but no error there.

Please help. I am stuck at this point. I am trying with iPhone simulator.

  • 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-23T15:20:00+00:00Added an answer on May 23, 2026 at 3:20 pm

    Finally, i found the problem in my code. And this solution apply to every client side technology.

    Let’s see the working code first:

    var data_to_send = '{"userid": "' + bh.userID + '", "touserid": "' + bh.logic.profile.userID + '","message": "' + bh.ui.postMessage.txtPost.value + '"}';
    var request = Titanium.Network.createHTTPClient();
    request.onload = function() {
       //Some code here
    };
    request.onerror = function(){
       //Some code here
    };
    request.open("POST", bh.serverAddress + "MyCareer.svc/PostMessage");
    request.setRequestHeader("enctype", "multipart/form-data");
    request.setRequestHeader("Content-Type", "application/json; charset=utf-8");
    request.send(data_to_send); 
    

    Fixes:

    1. The json data that i was sending was not in correct format. I created a json string as it should had been consumed in the local javascript. But, my json had to be consumed by WCF. So, it should remain json by the time it reaches there. Notice the use of single and double quotes. They should be like they are. I think interchanging them should also not work because single quotes in Asp.net means a character and not string.
    2. Notice the use of header information that i am sending. I think some variation in it shall work, but atleast application/json thing is required.

    Hope that helps. whole point is that what you deem is correct for javascript is not correct for json.

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

Sidebar

Related Questions

The below code is not working <c:forEach var=row varStatus=rowCount begin=1 end=10> <c:set var=entry scope=request
for below code var str = I left the United States with my eyes
I've got the below code: // Initiate the font choosing lists. var headerListWindow =
The below code which uses npoi to create excel documents displays images in open
My code below is a simple Titanium mobile application for Android. I implemented database
I am using Appcelerator Titanium for an Android app and the code below generates
The below code works as far as I can tell except for the var
Below code saying error incorreect syntax near Main INSERT INTO tbl ( 'Week', Main,
The below code is very simple. I have a jQuery autocomplete bound to an
My below code works fine and is used to populate a <select> item with

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.