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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T00:01:26+00:00 2026-06-07T00:01:26+00:00

The get works fine and able to post to the database with a test

  • 0

The get works fine and able to post to the database with a test winform app but getting a error 400 from the IIS log when trying to do a POST from iOS app. This is the IIS log 2012-06-28 12:13:39 192.168.100.112 POST /JsonWcfService/GetEmployees.svc/json/updateuser – 58129 – 192.168.100.231 WcfTest/1.0+CFNetwork/548.0.3+Darwin/11.4.0 400 0 0 4163

This is the WCF service code

    [OperationContract]
    [WebInvoke(Method = "POST",
       ResponseFormat = WebMessageFormat.Json,
       RequestFormat = WebMessageFormat.Json,
       BodyStyle = WebMessageBodyStyle.Wrapped,
       UriTemplate = "json/updateuser")]
    //method
     Employee PostEmp(Employee emp);    

[DataContract]
public class Employee
{
    [DataMember]
    public string firstname { get; set; }
    [DataMember]
    public string lastname { get; set; }
    [DataMember]
    public decimal salary { get; set; }
    [DataMember]
    public int idkey { get; set; }
    public Employee()
    {

    }
}

public Employee GetEmp(int IDKey)
{
    Employee emp = new Employee();

    using (EmpDBEntities empContext = new EmpDBEntities())
    {
        var j = (from t in empContext.EMPKeys where t.IDKey == IDKey select t).FirstOrDefault();
        emp = (new Employee(j.FirstName, j.LastName, j.Salary, j.IDKey));
        return emp;
    }
 }

xcode was taken from another posting on this site.

NSArray *keys = [NSArray arrayWithObjects:@"idkey", @"firstname", @"lastname",@"salary", nil];
NSArray *objects = [NSArray arrayWithObjects:@"1", @"jim", @"jones", @"450",nil];
NSData *__jsonData = nil;
NSString *__jsonString = nil;
NSURL *url = [NSURL
URLWithString:@"http://<ip address>/JsonWcfService/GetEmployees.svc/json/updateuser"];

NSDictionary *jsonDictionary = [NSDictionary dictionaryWithObjects:objects forKeys:keys];

if([NSJSONSerialization isValidJSONObject:jsonDictionary])
{
    __jsonData = [NSJSONSerialization dataWithJSONObject:jsonDictionary options:0 error:nil];
    __jsonString = [[NSString alloc]initWithData:__jsonData encoding:NSUTF8StringEncoding];
}

// Be sure to properly escape your url string.
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
[request setHTTPMethod:@"POST"];
[request setHTTPBody: __jsonData];
[request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
[request setValue:[NSString stringWithFormat:@"%d", [__jsonData length]] forHTTPHeaderField:@"Content-Length"];

NSError *errorReturned = nil;
NSURLResponse *theResponse =[[NSURLResponse alloc]init];
NSData *data = [NSURLConnection sendSynchronousRequest:request returningResponse:&theResponse error:&errorReturned];

if (errorReturned) {
    // Handle error.
}
else
{
    NSError *jsonParsingError = nil;
    NSArray *jsonArray = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers|NSJSONReadingAllowFragments

error:&jsonParsingError];
}

  • 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-07T00:01:27+00:00Added an answer on June 7, 2026 at 12:01 am

    Issue was in the implementation file changed modifed two lines and works now.

    [OperationContract]
    [WebInvoke(Method = "POST",
       ResponseFormat = WebMessageFormat.Json,
       RequestFormat = WebMessageFormat.Json,
       //BodyStyle = WebMessageBodyStyle.Wrapped, removed this line otherwise the Employee object was null
       //UriTemplate = "json/updateuser")
    UriTemplate =""] //removed "json/updateuser and was able to post to the DB
    //method
     Employee PostEmp(Employee emp);    
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm posting data from a Flex app to a php script. GET works fine
Following works fine in shell: >>> from django.contrib.auth.models import User >>> user=User.objects.get(pk=1) >>> user.first_name
My WPF application works fine on a number of machines, but now I get
parentId=$(this).closest('tr').find('td:nth(6)')[0].textContent; I am trying to get ID from flexigrid column. It works fine in
I've been able to get my autosave to work fine for input boxes and
This works fine: GET /mvc/Movies/TitleIncludes/Lara%20Croft When I submit a request that contains a colon,
My local copy works fine, then I publish the website and I get this
I am using javascript to get the referring page (document.referrer) which works fine and
I swear this script worked fine last night but can't get it to work
I have the following handler in my page that works fine in Firefox, but

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.