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 4332924
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T10:19:22+00:00 2026-05-21T10:19:22+00:00

I have an iPhone simulator app as client and WCF-REST, json encoded service running

  • 0

I have an iPhone simulator app as client and WCF-REST, json encoded service running on IIS 7.0 server.
I’m trying to send some hebrew characters to the service as parameter and the server return error code 400 – Bad Request.
When I’m sending an English string the server processes the string as it should.

The code used for the string encoding looks like this:

Note that “parameters” is the parameters that about to be sent to the server, ordered as parameter_name => parameter_value.

//RPC JSON
NSString* reqString = [parameters JSONRepresentation];
//Request
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url];
NSData* requestData = [NSData dataWithBytes:[reqString UTF8String] length:[reqString length]];
//prepare http body
[request setHTTPMethod: @"POST"];
[request setValue:[NSString stringWithFormat:@"%d", [requestData length]] forHTTPHeaderField:@"Content-Length"];
[request setValue:@"application/json" forHTTPHeaderField:@"Accept"];
[request setValue:@"application/json; charset=UTF-8" forHTTPHeaderField:@"Content-Type"];
[request setHTTPBody: requestData];
urlConnection = [[NSURLConnection alloc] initWithRequest:request delegate:self startImmediately:YES];

The request and response I’m getting in the server side (got this by using ethereal):

Request:

POST /SmsliMobileService.svc/SetContactGroups HTTP/1.1
Host: 192.168.10.22:8081
User-Agent: Beeper_3/1.0 CFNetwork/485.12.7 Darwin/10.7.0
Content-Length: 89
Accept: application/json
Content-Type: application/json; charset=UTF-8
Accept-Language: en-us
Accept-Encoding: gzip, deflate
Connection: keep-alive

Response:

{"ApplicationID":"98534bb6-82ef-4937-83e7-10f65780bf36","contact_id":43,"groups":"עבו×HTTP/1.1 400 Bad Request
Content-Length: 1647
Content-Type: text/html
Server: Microsoft-IIS/7.5
X-Powered-By: ASP.NET
Date: Sun, 10 Apr 2011 07:46:09 GMT

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"             "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <title>Request Error</title>
    <style>BODY { color: #000000; background-color: white; font-family: Verdana; margin-    left: 0px; margin-top: 0px; } #content { margin-left: 30px; font-size: .70em; padding-    bottom: 2em; } A:link { color: #336699; font-weight: bold; text-decoration: underline; }     A:visited { color: #6699cc; font-weight: bold; text-decoration: underline; } A:active {     color: #336699; font-weight: bold; text-decoration: underline; } .heading1 { background-    color: #003366; border-bottom: #336699 6px solid; color: #ffffff; font-family: Tahoma; font-    size: 26px; font-weight: normal;margin: 0em 0em 10px -20px; padding-bottom: 8px; padding-    left: 30px;padding-top: 16px;} pre { font-size:small; background-color: #e5e5cc; padding:     5px; font-family: Courier New; margin-top: 0px; border: 1px #f0f0e0 solid; white-space: pre-    wrap; white-space: -pre-wrap; word-wrap: break-word; } table { border-collapse: collapse;     border-spacing: 0px; font-family: Verdana;} table th { border-right: 2px white solid;     border-bottom: 2px white solid; font-weight: bold; background-color: #cecf9c;} table td {     border-right: 2px white solid; border-bottom: 2px white solid; background-color: #e5e5cc;}    </style>
  </head>
  <body>
    <div id="content">
      <p class="heading1">Request Error</p>
      <p>The server encountered an error processing the request. See server logs for     more details.</p>
    </div>
  </body>
</html>

Any help will be appreciated.

  • 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-21T10:19:23+00:00Added an answer on May 21, 2026 at 10:19 am

    I had an error on the posted code.

    NSData* requestData = [NSData dataWithBytes:[reqString UTF8String] length:[reqString length]];
    

    This line (was originally in the question’s code) generated the error – instead of taking the length of the bytes array returned from: “[reqString UTF8String]”, a wrong length had been given – the length of the nsstring…

    The fixed code:

    const char *utf8String = [reqString UTF8String];    // no need to free me - autoreleased  object returned.
    NSInteger l = strlen(utf8String);
    NSData *requestData = [NSData dataWithBytes:utf8String length:l];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an iPhone app that compiles and runs fine in the Simulator on
I have an iphone simulator running on my Mac. I have a .ipa file,
I have an app which I am testing using the iPhone simulator. When I
I have an app that makes request to a REST service. Authentication is done
I have created an iPhone app which works perfectly smooth on my simulator. Now
I have an iPhone app that hides the status bar. However, my main view
I have an iphone app where I call these three functions in appDidFinishLaunching: glMatrixMode(GL_PROJECTION);
I have a simple iphone app that's based on the CrashLanding sample app. So
I want to be able to send files from an iPhone app to a
I have put my iPhone app in landscape mode and I want to put

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.