当前位置:网站首页>AFNetworking data-raw请求方式
AFNetworking data-raw请求方式
2022-07-21 17:39:00 【沐梓弦乐】
传统的请求方式 代码如下
// 设置超时时间
[session.requestSerializer willChangeValueForKey:@"timeoutInterval"];
session.requestSerializer.timeoutInterval = 10.f;
[session.requestSerializer didChangeValueForKey:@"timeoutInterval"];
[session POST:url parameters:params headers:nil progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
}]
但是这样的调用方式是按照form-data的方式调用的 ,并不是放到body里面的方式
JSON(data-raw)请求方式 代码如下
//请求头
[session.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
session.requestSerializer = [AFJSONRequestSerializer serializer];
[session.requestSerializer willChangeValueForKey:@"timeoutInterval"];
session.requestSerializer.timeoutInterval = 10.f;
[session.requestSerializer didChangeValueForKey:@"timeoutInterval"];
[session POST:url parameters:params headers:nil progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
}];
边栏推荐
猜你喜欢
海思Hi3531||瑞芯微RK1109用rtsp客户端实现h264拉流
Module build failed: Error: Plugin/Preset files are not allowed to export objects, only functions.
How to build a smart park with 5g and mobile edge computing servers
一种图片选择自定义控件
openlayers 使用canvas绘制圆形头像图标
[三星6818]gpio模拟spi信号编写门禁卡识别模块驱动
[C language] document operation "I"
三星6818基于uboot的流水灯程序
win7下在安装Oracle10g时出现【安装检测到系统的主 IP 地址是 DHCP 分配的地址】的错误的解决办法
鼠标移入select options会触发mouseleave 事件处理方案
随机推荐
基于[海思Hi3516dv300]开发的内核定时器中断
v-7
Hisilicon [hi3531]gpio lighting application and register operation
ts 学习记录(一)sudo忘记密码(乌龙)Try changing the ‘lib’ compiler option to include ‘dom’.
开户华泰证券安全吗,在哪开靠谱一些
多线程与线程池
RT-Thread中常用的指令
一道数据库查询面试题
自定义图片裁剪框
三星6818LED驱动的编写
Pointer depth solution "three" (array cognition)
Writing of Samsung 6818led driver
我心目中理想的“元宇宙”
ES版i9-13900K亮相CPU-Z数据库 跑分数据过于谦虚
Guan Zhengxiong: implement QA generation algorithm based on pre training model and intelligent operation and maintenance
Cloud security daily 220721: Cisco hybrid cloud operation and maintenance management solution found the vulnerability of executing arbitrary commands, which needs to be upgraded as soon as possible
人脑的算力真的很弱吗
js判断是否为整数
[compilation record of Ruixin micro rk1109_rk1126 rkmedia]
刨根问底丨落后的技术,能否造出好卖的产品?