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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T03:25:18+00:00 2026-06-04T03:25:18+00:00

When I send a request to my web-service with utf-8 special characters, such as

  • 0

When I send a request to my web-service with utf-8 special characters, such as “Ö”, it return response 500 “There was an error processing the request” This is what I log in the iOS app.

- (void)connectionDidFinishLoading:(NSURLConnection *)connection
{    
    NSError *error = nil;

    dict = [[CJSONDeserializer deserializer] deserializeAsDictionary:self.responseData error:&error];
    for (id key in dict) {
        NSLog(@"%@=%@", key, [dict objectForKey:key]);
    }

If I send a message with just plain english it works fine.

I’m not sure if the error is on the server-side or in the app itself.
This is how I send my JSON POST:

    - (void)stringWithUrl:(NSURL *)url jsonReq:(NSString *)json{

    self.requestURL = [[[NSMutableURLRequest alloc] initWithURL:url] autorelease];
    self.responseData = [NSData dataWithBytes:[json UTF8String] length:[json length]];


    [self.requestURL setHTTPMethod:@"POST"];
    [self.requestURL setValue:@"application/json" forHTTPHeaderField:@"Accept"];
    [self.requestURL setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
    [self.requestURL setValue:@"application/json" forHTTPHeaderField:@"UTF-8"];
    [self.requestURL setValue:[NSString stringWithFormat:@"%d", [self.responseData length]] forHTTPHeaderField:@"Content-Length"];
    [self.requestURL setHTTPBody: self.responseData];

And this is how the web-service look:

    ....    
[WebService(Namespace = "http://mypage.com/webservicesF")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    // To allow this Web Service to be called from script, using ASP.NET AJAX,
    [System.Web.Script.Services.ScriptService]
.....
    [WebMethod]
    [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
  • 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-06-04T03:25:20+00:00Added an answer on June 4, 2026 at 3:25 am

    This line:

    self.responseData = [NSData dataWithBytes:[json UTF8String] length:[json length]];
    

    is incorrect. An NSString‘s length is in UTF-16 characters, not UTF-8 characters. You could do something like:

    const char* utf8 = [json UTF8String];
    self.responseData = [NSData dataWithBytes:utf8 length:strlen(utf8)];
    

    but the better way is to just have the string create the NSData directly, without going through a C-style string.

    self.responseData = [json dataUsingEncoding:NSUTF8StringEncoding];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to send a request to a web service, and read the response.
I want to send a request to a web service, and read the response.
I wrote REST service using ASP.NET Web API. I'm trying to send HttpDelete request,
How to send a HTTP request to a web service using Objective-C ? I
I'm trying to send a simple POST request to a REST web service and
I've a problem. I try to send a JSON request to a web server
I am using JSON-RPC. When i send request to server i get a response
I'm using StringBuffer to send and receive variables from a web service. My code
SO I post this json to this restful web service and the post is
In my application I'm using outpost method to send data to web service which

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.