My WCF Web Service (svc-file) returns Request Error when trying to send data in json including danish characters like æ, ø, å.
In my iOS app i’m making the request like this:
NSData *requestData = [NSData dataWithBytes:[jsonRequest UTF8String] length:[jsonRequest length]];
[request setHTTPMethod:@"POST"];
[request setValue:@"application/json" forHTTPHeaderField:@"Accept"];
[request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
[request setValue:[NSString stringWithFormat:@"%d", [requestData length]] forHTTPHeaderField:@"Content-Length"];
[request setHTTPBody: requestData];
My WCF service interface looks like this:
[OperationContract]
[WebInvoke(Method = "POST", BodyStyle=WebMessageBodyStyle.WrappedRequest, RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, UriTemplate = "/createNewPost")]
NewPostReply CreateNewPost(CreatePostCredential createPostCredential);
Everything works perfectly when i don’t send “æ ø å”, but i get the error when including “æ ø å”.
Do i have to change something in the operation contract or in web.config?
This is what I do:
Instead of sending request data in NSData, I send a string and set that to use NSUTF8StringEncoding.