使用键和值发布Json数据

时间:2016-11-05 06:50:06

标签: ios objective-c json

我发布了一个带有url及其参数的JSON数据。问题是,当我在邮递员中发帖时,我得到"status": "Success","msg": "You Membership Form Submitted SuccessFully",但是当我将其发布在我的Xcode 7.2.1中时,它会给出"status":"Failed","msg":"You Membership Form did not Submit SuccessFully"。所以请建议我如何解决它。

我的方式如下: -

NSURL *baseUrl=[NSURL URLWithString:baseUrlStringForMembershipPageToSubmitdata];

NSDictionary *mapData=@{@"field_name_value":@{@"_levelOfMembershipTableView":@"menu-291"},@{@"_upgradeMembershipTableView":@"menu-565"},@{@"_detailsTableView":@"menu-696"},@{@"_txtFirstNameMembership.text":@"text-708"},@{@"_txtLastNameMembership.text":@"text-274"},@{@"_txtDOBMembership.text":@"text-443"},@{@"_txtCompanyNameMembership.text":@"text-970"},@{@"_txtJobTitleMembership.text":@"text-961"},@{@"_txtAddressMembership.text":@"text-785"},@{@"_txtCityMembership.text":@"text-482"},@{@"_txtPostCodeMembership.text":@"text-760"},@{@"_countryTableView":@"menu-19"},@{@"_txtEmailMembership.text":@"text-577"},@{@"_txtHomePhoneMembership.text":@"text-760"},@{@"_txtMobilePhoneMembership.text":@"text-394"},@{@"_txtWorkPhoneMembership.text":@"text-914"},@{@"_contactByTableView":@"menu-373"},@{@"_interestedInTableView":@"menu-527"},@{@"_hearAboutUsTableView":@"menu-997"} };

AFHTTPSessionManager *manager=[AFHTTPSessionManager manager];
manager.responseSerializer=[AFJSONResponseSerializer serializer];

[manager POST:baseUrlStringForMembershipPageToSubmitdata parameters:mapData constructingBodyWithBlock:^(id<AFMultipartFormData> formData)
 {
 }
     progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject)
 {
     NSLog(@"%@",responseObject);
 }
      failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error)
 {
     NSLog(@"Errorrrrrrr=%@",error.localizedDescription);
     UIAlertController *alertValidator2=[UIAlertController alertControllerWithTitle:@"Please fill correctly" message:@"!!!" preferredStyle:UIAlertControllerStyleActionSheet];
     UIAlertAction *alertaction2=[UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {}];
     [alertValidator2 addAction:alertaction2];
     [self presentViewController:alertValidator2 animated:YES completion:nil];
 }];

我发送“field_name_value”作为密钥。我寄给邮递员的参数是: -

键 - field_name_value值 -

[
    {
        "field_value": "_levelOfMembershipTableView",
        "field_name": "menu-291"
    },
    {
        "field_value": "_upgradeMembershipTableView",
        "field_name": "menu-565"
    },
    {
        "field_value": "_detailsTableView",
        "field_name": "menu-696"
    },
    {
        "field_value": "_txtFirstNameMembership.text",
        "field_name": "text-708"
    },
    {
        "field_value": "_txtLastNameMembership.text",
        "field_name": "text-274"
    },
    {
        "field_value": "_txtDOBMembership.text",
        "field_name": "text-443"
    },
    {
        "field_value": "_txtCompanyNameMembership.text",
        "field_name": "text-970"
    },
    {
        "field_value": "_txtJobTitleMembership.text",
        "field_name": "text-961"
    },
    {
        "field_value": "_txtAddressMembership.text",
        "field_name": "text-785"
    },
    {
        "field_value": "_txtCityMembership.text",
        "field_name": "text-482"
    },
    {
        "field_value": "_txtPostCodeMembership.text",
        "field_name": "text-760"
    },
    {
        "field_value": "_countryTableView",
        "field_name": "menu-19"
    },
    {
        "field_value": "_txtEmailMembership.text",
        "field_name": "text-577"
    },
    {
        "field_value": "_txtHomePhoneMembership.text",
        "field_name": "text-760"
    },
    {
        "field_value": "_txtMobilePhoneMembership.text",
        "field_name": "text-394"
    },
    {
        "field_value": "_txtWorkPhoneMembership.text",
        "field_name": "text-914"
    },
    {
        "field_value": "_contactByTableView",
        "field_name": "menu-373"
    },
    {
        "field_value": "_interestedInTableView",
        "field_name": "menu-527"
    },
    {
        "field_value": "_hearAboutUsTableView",
        "field_name": "menu-997"
    }
]

0 个答案:

没有答案