ios - 如何使用AFNetworking在Http请求中发送json数据

标签 ios json afnetworking jsonresponse

我必须向服务器传递json格式的数据

{"email":"abc@gmail.com","password":"abc"}

我已经使用了这个代码但是数据没有传递到服务器请帮助我..

    NSDictionary *dict1=@{@"email": @"biren123@gmail.com"};
    NSDictionary *dict2=@{@"password": @"biren"};
    services *srv=[[services alloc]init];

    NSString *str=@"http://emailsending.in/setting_saver_api/";
    NSString *method=@"login.php";
    NSMutableDictionary *dict=[[NSMutableDictionary alloc]init];

    [dict setValue:dict1 forKey:@"email"];

    [dict setValue:dict2 forKey:@"password"];


    [srv postToURL:str withMethod:method andParams:dict completion:^(BOOL success, NSDictionary *responseObj)

     {
         NSLog(@"res :%@",responseObj);
         NSLog(@"%d",success);

         NSLog(@"Successfully..................");


     }];

最佳答案

您可以在以下位置查看您的链接 https://www.hurl.it/

1)给你的http链接

2) 选择你的方法类型“Get”或“Post”

3)添加参数

并检查响应。如果您收到相同的响应,请联系您的后端团队。

关于ios - 如何使用AFNetworking在Http请求中发送json数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35238085/

相关文章:

objective-c - 如何从 iOS 中的 URL 获取图像大小

ios - Firebase 可以离线使用 React Native 吗?

iOS MDM 创建信任问题

javascript - Yeoman 生成器在全局安装时找不到 .yo-rc.json 文件

ios - 委托(delegate)在 AFNetworking 响应 block 中变为 nil?

ios - 服务 API 调用阻止 UITableViewController 中的 UI

iphone - 每30秒UILocalNotification

ios - 在 XCode : Signature invalid 之外测试 iCloud

javascript - 从按钮中删除 ng-grid 表中的行

javascript - 根据某些属性和值过滤 JSON 数据